Class DateTimeUtil


  • public class DateTimeUtil
    extends Object
    This class has some methods for finding some special time points.
    • 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
    • Constructor Detail

      • DateTimeUtil

        public DateTimeUtil()
    • Method Detail

      • getStartOfDay

        public static Calendar getStartOfDay()
        This method returns a Calendar 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 a Calendar object at the beginning of the given day.
        Parameters:
        date - The Date for which the start of day should be computed.
        Returns:
        The Calendar object at the beginning of this 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 a Calendar 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 a Calendar object at the beginning of the given month and year. The date will be 00:00 01.month.year. Note: The month is not in Calendar notation. January has the value of 1 and not Calendar.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 a Calendar 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 in Calendar notation. January has the value of 1 and not Calendar.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.
      • setTime

        public static void setTime​(Calendar cal,
                                   int minute,
                                   int hour)
        This method sets the time of day.
        Parameters:
        cal - The Calendar to set the time.
        minute - The minute of the hour.
        hour - The hour of the day.