Package gw.date

Class GosuDateUtil


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

      • GosuDateUtil

        public GosuDateUtil()
    • Method Detail

      • addSeconds

        public static Date addSeconds​(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 Date addMinutes​(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 Date addHours​(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 Date addDays​(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 Date addWeeks​(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 Date addMonths​(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 Date addYears​(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​(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​(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​(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​(Date date)
        Is the time AM?
        Parameters:
        date - The time.
        Returns:
        true if the time is AM, false otherwise
      • isPM

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

        public static int getHourOfDay​(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​(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​(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​(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​(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​(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​(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​(Date date)
        Get the year.
        Parameters:
        date - The date.
        Returns:
        The year of the date.