Package gw.date

Class GosuDateUtil


  • public class GosuDateUtil
    extends java.lang.Object
    Utilities for java.util.Date objects. These utilities are not intended to be used directly; use the corresponding enhancements on Date instead.
    • Constructor Summary

      Constructors 
      Constructor Description
      GosuDateUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Date addDays​(java.util.Date date, int iDays)
      Adds the specified (signed) amount of days to the given date.
      static java.util.Date addHours​(java.util.Date date, int iHours)
      Adds the specified (signed) amount of hours to the given date.
      static java.util.Date addMinutes​(java.util.Date date, int iMinutes)
      Adds the specified (signed) amount of minutes to the given date.
      static java.util.Date addMonths​(java.util.Date date, int iMonths)
      Adds the specified (signed) amount of months to the given date.
      static java.util.Date addSeconds​(java.util.Date date, int iSeconds)
      Adds the specified (signed) amount of seconds to the given date.
      static java.util.Date addWeeks​(java.util.Date date, int iWeeks)
      Adds the specified (signed) amount of weeks to the given date.
      static java.util.Date addYears​(java.util.Date date, int iYears)
      Adds the specified (signed) amount of years to the given date.
      private static java.util.Calendar dateToCalendar​(java.util.Date date)  
      static int getDayOfMonth​(java.util.Date date)
      Get the day of month.
      static int getDayOfWeek​(java.util.Date date)
      Get the day of week.
      static int getDayOfYear​(java.util.Date date)
      Get the day of year.
      static int getHour​(java.util.Date date)
      Get the hour of the time, base on a 12-hour clock.
      static int getHourOfDay​(java.util.Date date)
      Get the hour of the time, based on a 24-hour clock.
      static int getMinute​(java.util.Date date)
      Get the minute of the time
      static int getMonth​(java.util.Date date)
      The month of the year.
      static int getSecond​(java.util.Date date)
      Get the second of the time
      static int getWeekOfMonth​(java.util.Date date)
      Get the week of month.
      static int getWeekOfYear​(java.util.Date date)
      Get the week of the year.
      static int getYear​(java.util.Date date)
      Get the year.
      static boolean isAM​(java.util.Date date)
      Is the time AM?
      static boolean isPM​(java.util.Date date)
      Is the time PM?
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GosuDateUtil

        public GosuDateUtil()
    • Method Detail

      • addSeconds

        public static java.util.Date addSeconds​(java.util.Date date,
                                                int iSeconds)
        Adds the specified (signed) amount of seconds to the given date. For example, to subtract 5 seconds from the current time of the date, you can achieve it by calling: addSeconds(Date, -5).
        Parameters:
        date - The time.
        iSeconds - The amount of seconds to add.
        Returns:
        A new date with the seconds added.
      • addMinutes

        public static java.util.Date addMinutes​(java.util.Date date,
                                                int iMinutes)
        Adds the specified (signed) amount of minutes to the given date. For example, to subtract 5 minutes from the current time of the date, you can achieve it by calling: addMinutes(Date, -5).
        Parameters:
        date - The time.
        iMinutes - The amount of minutes to add.
        Returns:
        A new date with the minutes added.
      • addHours

        public static java.util.Date addHours​(java.util.Date date,
                                              int iHours)
        Adds the specified (signed) amount of hours to the given date. For example, to subtract 5 hours from the current date, you can achieve it by calling: addHours(Date, -5).
        Parameters:
        date - The time.
        iHours - The amount of hours to add.
        Returns:
        A new date with the hours added.
      • addDays

        public static java.util.Date addDays​(java.util.Date date,
                                             int iDays)
        Adds the specified (signed) amount of days to the given date. For example, to subtract 5 days from the current date, you can achieve it by calling: addDays(Date, -5).
        Parameters:
        date - The time.
        iDays - The amount of days to add.
        Returns:
        A new date with the days added.
      • addWeeks

        public static java.util.Date addWeeks​(java.util.Date date,
                                              int iWeeks)
        Adds the specified (signed) amount of weeks to the given date. For example, to subtract 5 weeks from the current date, you can achieve it by calling: addWeeks(Date, -5).
        Parameters:
        date - The time.
        iWeeks - The amount of weeks to add.
        Returns:
        A new date with the weeks added.
      • addMonths

        public static java.util.Date addMonths​(java.util.Date date,
                                               int iMonths)
        Adds the specified (signed) amount of months to the given date. For example, to subtract 5 months from the current date, you can achieve it by calling: addMonths(Date, -5).
        Parameters:
        date - The time.
        iMonths - The amount of months to add.
        Returns:
        A new date with the months added.
      • addYears

        public static java.util.Date addYears​(java.util.Date date,
                                              int iYears)
        Adds the specified (signed) amount of years to the given date. For example, to subtract 5 years from the current date, you can achieve it by calling: addYears(Date, -5).
        Parameters:
        date - The time.
        iYears - The amount of years to add.
        Returns:
        A new date with the years added.
      • getSecond

        public static int getSecond​(java.util.Date date)
        Get the second of the time
        Parameters:
        date - The time.
        Returns:
        The second of the time, always in the range 0-59
      • getMinute

        public static int getMinute​(java.util.Date date)
        Get the minute of the time
        Parameters:
        date - The time.
        Returns:
        The minute of the time, always in the range 0-59
      • getHour

        public static int getHour​(java.util.Date date)
        Get the hour of the time, base on a 12-hour clock.
        Parameters:
        date - The time.
        Returns:
        The hour of the time. Based on a 12-hour clock.
      • isAM

        public static boolean isAM​(java.util.Date date)
        Is the time AM?
        Parameters:
        date - The time.
        Returns:
        true if the time is AM, false otherwise
      • isPM

        public static boolean isPM​(java.util.Date date)
        Is the time PM?
        Parameters:
        date - The time.
        Returns:
        true if the time is PM, false otherwise
      • getHourOfDay

        public static int getHourOfDay​(java.util.Date date)
        Get the hour of the time, based on a 24-hour clock.
        Parameters:
        date - The time.
        Returns:
        The hour of the time. Based on a 24-hour clock.
      • getDayOfWeek

        public static int getDayOfWeek​(java.util.Date date)
        Get the day of week.
        Parameters:
        date - The date.
        Returns:
        The day of week. Sunday = 1, Monday = 2, ..., Saturday = 7.
      • getDayOfMonth

        public static int getDayOfMonth​(java.util.Date date)
        Get the day of month.
        Parameters:
        date - The date.
        Returns:
        The day of the month. The first day = 1.
      • getDayOfYear

        public static int getDayOfYear​(java.util.Date date)
        Get the day of year.
        Parameters:
        date - The date.
        Returns:
        The day number of the year. The first day = 1.
      • getWeekOfMonth

        public static int getWeekOfMonth​(java.util.Date date)
        Get the week of month.
        Parameters:
        date - The date.
        Returns:
        The week within the month. The first week = 1.
      • getWeekOfYear

        public static int getWeekOfYear​(java.util.Date date)
        Get the week of the year.
        Parameters:
        date - The date.
        Returns:
        The week of the year. The first week = 1.
      • getMonth

        public static int getMonth​(java.util.Date date)
        The month of the year.
        Parameters:
        date - The date
        Returns:
        The month of the year, in the range 1-12
      • getYear

        public static int getYear​(java.util.Date date)
        Get the year.
        Parameters:
        date - The date.
        Returns:
        The year of the date.
      • dateToCalendar

        private static java.util.Calendar dateToCalendar​(java.util.Date date)