Package org.jeegen.jee6.util
Class DateTimeUtil
- java.lang.Object
-
- org.jeegen.jee6.util.DateTimeUtil
-
public class DateTimeUtil extends Object
This class has some methods for finding some special time points.
-
-
Field Summary
Fields Modifier and Type Field Description static long
DAYS_PER_WEEK
This constant defines the days per week.static long
DAYS_PER_YEAR
This constant defines the days per year.static long
HOURS_PER_DAY
This constant defines the hours per day.static long
MILLIES_PER_DAY
This constant defines the milli seconds per day.static long
MILLIES_PER_HOUR
This constant defines the milli seconds per hour.static long
MILLIES_PER_MINUTE
This constant defines the milli seconds per minute.static long
MINUTES_PER_DAY
This constant defines the minutes per day.static long
MINUTES_PER_HOUR
This constant defines the minutes per hour.static long
SECONDS_PER_HOUR
This constant defines the seconds per hour.static long
SECONDS_PER_MINUTE
This constant defines the seconds per minute.
-
Constructor Summary
Constructors Constructor Description DateTimeUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Calendar
getLastMonth()
This method returns the month before the actual one.static Calendar
getStartOfDay()
This method returns aCalendar
object at the beginning of this day.static Calendar
getStartOfDay(int day, int month, int year)
This method returns aCalendar
object at the beginning of the given day, month and year.static Calendar
getStartOfDay(Date date)
This method returns aCalendar
object at the beginning of the given day.static Calendar
getStartOfMonth(int month, int year)
This method returns aCalendar
object at the beginning of the given month and year.static Calendar
getStartOfYear(int year)
This method returns aCalendar
object at the beginning of the given year.static void
setTime(Calendar cal, int minute, int hour)
This method sets the time of day.
-
-
-
Field Detail
-
MILLIES_PER_MINUTE
public static final long MILLIES_PER_MINUTE
This constant defines the milli seconds per minute.
-
MILLIES_PER_HOUR
public static final long MILLIES_PER_HOUR
This constant defines the milli seconds per hour.
-
MILLIES_PER_DAY
public static final long MILLIES_PER_DAY
This constant defines the milli seconds per day.
-
SECONDS_PER_MINUTE
public static final long SECONDS_PER_MINUTE
This constant defines the seconds per minute.
-
SECONDS_PER_HOUR
public static final long SECONDS_PER_HOUR
This constant defines the seconds per hour.
-
MINUTES_PER_HOUR
public static final long MINUTES_PER_HOUR
This constant defines the minutes per hour.
-
MINUTES_PER_DAY
public static final long MINUTES_PER_DAY
This constant defines the minutes per day.
-
HOURS_PER_DAY
public static final long HOURS_PER_DAY
This constant defines the hours per day.
-
DAYS_PER_WEEK
public static final long DAYS_PER_WEEK
This constant defines the days per week.- See Also:
- Constant Field Values
-
DAYS_PER_YEAR
public static final long DAYS_PER_YEAR
This constant defines the days per year.- See Also:
- Constant Field Values
-
-
Method Detail
-
getStartOfDay
public static Calendar getStartOfDay()
This method returns aCalendar
object at the beginning of this day.- Returns:
- The
Calendar
object at the beginning of this day.
-
getStartOfDay
public static Calendar getStartOfDay(Date date)
This method returns aCalendar
object at the beginning of the given day.
-
getLastMonth
public static Calendar getLastMonth()
This method returns the month before the actual one. The day is the same as the actual one but with the beginning of the day.- Returns:
- The time point exactly one month ago ant the beginning of the day.
-
getStartOfYear
public static Calendar getStartOfYear(int year)
This method returns aCalendar
object at the beginning of the given year. The date will be 00:00 01.01.year.- Parameters:
year
- The year to compute the beginning from.- Returns:
- The beginning of the specified year.
-
getStartOfMonth
public static Calendar getStartOfMonth(int month, int year)
This method returns aCalendar
object at the beginning of the given month and year. The date will be 00:00 01.month.year. Note: The month is not inCalendar
notation. January has the value of 1 and notCalendar
.JANUARY!- Parameters:
month
- The month to compute the beginning from.year
- The year to compute the beginning from.- Returns:
- The beginning of the specified month and year.
-
getStartOfDay
public static Calendar getStartOfDay(int day, int month, int year)
This method returns aCalendar
object at the beginning of the given day, month and year. The date will be 00:00 day.month.year. Note: The month is not inCalendar
notation. January has the value of 1 and notCalendar
.JANUARY!- Parameters:
day
- The day to compute the beginning from.month
- The month to compute the beginning from.year
- The year to compute the beginning from.- Returns:
- The beginning of the specified month and year.
-
-