Package: groovy.time

## [Java] Class TimeCategory

- groovy.time.TimeCategory

-     public class TimeCategory
      extends Object

  Apply a number of methods to allow convenient Date/Time manipulation,such as:

       use (groovy.time.TimeCategory) {
           // application on numbers:
           println 1.minute.from.now
           println 10.hours.ago

           // application on dates
           def someDate = new Date()
           println someDate - 3.months
       }

  See Also:
    BaseDuration

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static Duration` | `getDay(Integer self)` Alias for getDays(Integer).
    `` | `public static Duration` | `getDaylightSavingsOffset(Date self)` Get the DST offset (if any) for the default locale and the given date.
    `` | `public static Duration` | `getDaylightSavingsOffset(BaseDuration self)` Gets the daylight savings offset for the supplied duration interpreted as a date.
    `` | `public static Duration` | `getDays(Integer self)` Returns a day-based duration for the supplied number of days.
    `` | `public static TimeDuration` | `getHour(Integer self)` Alias for getHours(Integer).
    `` | `public static TimeDuration` | `getHours(Integer self)` Returns an hour-based duration for the supplied number of hours.
    `` | `public static TimeDuration` | `getMillisecond(Integer self)` Alias for getMilliseconds(Integer).
    `` | `public static TimeDuration` | `getMilliseconds(Integer self)` Returns a millisecond-based duration for the supplied number of milliseconds.
    `` | `public static TimeDuration` | `getMinute(Integer self)` Alias for getMinutes(Integer).
    `` | `public static TimeDuration` | `getMinutes(Integer self)` Returns a minute-based duration for the supplied number of minutes.
    `` | `public static DatumDependentDuration` | `getMonth(Integer self)` Alias for getMonths(Integer).
    `` | `public static DatumDependentDuration` | `getMonths(Integer self)` Returns a month-based duration for the supplied number of months.
    `` | `public static Duration` | `getRelativeDaylightSavingsOffset(Date self, Date other)` Return a Duration representing the DST difference (if any) between two dates.
    `` | `public static TimeDuration` | `getSecond(Integer self)` Alias for getSeconds(Integer).
    `` | `public static TimeDuration` | `getSeconds(Integer self)` Returns a second-based duration for the supplied number of seconds.
    `` | `public static TimeZone` | `getTimeZone(Date self)` Retrieves the default TimeZone for a date by using the default Locale settings.
    `` | `public static Duration` | `getWeek(Integer self)` Alias for getWeeks(Integer).
    `` | `public static Duration` | `getWeeks(Integer self)` Returns a week-based duration for the supplied number of weeks.
    `` | `public static DatumDependentDuration` | `getYear(Integer self)` Alias for getYears(Integer).
    `` | `public static DatumDependentDuration` | `getYears(Integer self)` Returns a year-based duration for the supplied number of years.
    `` | `public static Date` | `minus(Date date, BaseDuration duration)` Subtracts a duration from a date.
    `` | `public static TimeDuration` | `minus(Date lhs, Date rhs)` Subtract one date from the other.
    `` | `public static Date` | `plus(Date date, BaseDuration duration)` Adds a duration to a date.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### public static Duration getDay(Integer self)

      Alias for getDays(Integer).

      Parameters:
        `self` - the number of days
      Returns:
        the corresponding duration

    - #### public static Duration getDaylightSavingsOffset(Date self)

      Get the DST offset (if any) for the default locale and the given date.

      Parameters:
        `self` - a Date
      Returns:
        the DST offset as a Duration.

    - #### public static Duration getDaylightSavingsOffset(BaseDuration self)

      Gets the daylight savings offset for the supplied duration interpreted as a date.

      Parameters:
        `self` - the duration to inspect
      Returns:
        the DST offset as a duration

    - #### public static Duration getDays(Integer self)

      Returns a day-based duration for the supplied number of days.

      Parameters:
        `self` - the number of days
      Returns:
        the corresponding duration

    - #### public static TimeDuration getHour(Integer self)

      Alias for getHours(Integer).

      Parameters:
        `self` - the number of hours
      Returns:
        the corresponding duration

    - #### public static TimeDuration getHours(Integer self)

      Returns an hour-based duration for the supplied number of hours.

      Parameters:
        `self` - the number of hours
      Returns:
        the corresponding duration

    - #### public static TimeDuration getMillisecond(Integer self)

      Alias for getMilliseconds(Integer).

      Parameters:
        `self` - the number of milliseconds
      Returns:
        the corresponding duration

    - #### public static TimeDuration getMilliseconds(Integer self)

      Returns a millisecond-based duration for the supplied number of milliseconds.

      Parameters:
        `self` - the number of milliseconds
      Returns:
        the corresponding duration

    - #### public static TimeDuration getMinute(Integer self)

      Alias for getMinutes(Integer).

      Parameters:
        `self` - the number of minutes
      Returns:
        the corresponding duration

    - #### public static TimeDuration getMinutes(Integer self)

      Returns a minute-based duration for the supplied number of minutes.

      Parameters:
        `self` - the number of minutes
      Returns:
        the corresponding duration

    - #### public static DatumDependentDuration getMonth(Integer self)

      Alias for getMonths(Integer).

      Parameters:
        `self` - the number of months
      Returns:
        the corresponding duration

    - #### public static DatumDependentDuration getMonths(Integer self)

      Returns a month-based duration for the supplied number of months.

      Parameters:
        `self` - the number of months
      Returns:
        the corresponding duration

    - #### public static Duration getRelativeDaylightSavingsOffset(Date self, Date other)

      Return a Duration representing the DST difference (if any) between two dates. i.e. if one date is before the DST changeover, and the other date is after, the resulting duration will represent the DST offset.

      Parameters:
        `self` - a Date
        `other` - another Date
      Returns:
        a Duration

    - #### public static TimeDuration getSecond(Integer self)

      Alias for getSeconds(Integer).

      Parameters:
        `self` - the number of seconds
      Returns:
        the corresponding duration

    - #### public static TimeDuration getSeconds(Integer self)

      Returns a second-based duration for the supplied number of seconds.

      Parameters:
        `self` - the number of seconds
      Returns:
        the corresponding duration

    - #### @Deprecated
      public static TimeZone getTimeZone(Date self)

      Retrieves the default TimeZone for a date by using the default Locale settings. Recommended that you use `TimeZone.getDefault()` instead.

      Parameters:
        `self` - a Date
      Returns:
        the TimeZone

    - #### public static Duration getWeek(Integer self)

      Alias for getWeeks(Integer).

      Parameters:
        `self` - the number of weeks
      Returns:
        the corresponding duration

    - #### public static Duration getWeeks(Integer self)

      Returns a week-based duration for the supplied number of weeks.

      Parameters:
        `self` - the number of weeks
      Returns:
        the corresponding duration

    - #### public static DatumDependentDuration getYear(Integer self)

      Alias for getYears(Integer).

      Parameters:
        `self` - the number of years
      Returns:
        the corresponding duration

    - #### public static DatumDependentDuration getYears(Integer self)

      Returns a year-based duration for the supplied number of years.

      Parameters:
        `self` - the number of years
      Returns:
        the corresponding duration

    - #### public static Date minus(Date date, BaseDuration duration)

      Subtracts a duration from a date.

      Parameters:
        `date` - the base date
        `duration` - the duration to subtract
      Returns:
        the adjusted date

    - #### public static TimeDuration minus(Date lhs, Date rhs)

      Subtract one date from the other.

      Parameters:
        `lhs` - a Date
        `rhs` - another Date
      Returns:
        a Duration

    - #### public static Date plus(Date date, BaseDuration duration)

      Adds a duration to a date.

      Parameters:
        `date` - the base date
        `duration` - the duration to add
      Returns:
        the adjusted date