Package groovy.time

# Class TimeCategory

java.lang.Object
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`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TimeCategory()`

- ## Method Summary

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

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### TimeCategory

    public TimeCategory()

- ## Method Details

  - ### plus

    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

  - ### minus

    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

  - ### getTimeZone

    @Deprecated public static TimeZone getTimeZone(Date self)
    Deprecated.
    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

  - ### getDaylightSavingsOffset

    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.

  - ### getDaylightSavingsOffset

    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

  - ### getRelativeDaylightSavingsOffset

    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

  - ### minus

    public static TimeDuration minus(Date lhs, Date rhs)
    Subtract one date from the other.
    Parameters:
      `lhs` - a Date
      `rhs` - another Date
    Returns:
      a Duration

  - ### getMonths

    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

  - ### getMonth

    public static DatumDependentDuration getMonth(Integer self)
    Alias for `getMonths(Integer)`.
    Parameters:
      `self` - the number of months
    Returns:
      the corresponding duration

  - ### getYears

    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

  - ### getYear

    public static DatumDependentDuration getYear(Integer self)
    Alias for `getYears(Integer)`.
    Parameters:
      `self` - the number of years
    Returns:
      the corresponding duration

  - ### getWeeks

    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

  - ### getWeek

    public static Duration getWeek(Integer self)
    Alias for `getWeeks(Integer)`.
    Parameters:
      `self` - the number of weeks
    Returns:
      the corresponding duration

  - ### getDays

    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

  - ### getDay

    public static Duration getDay(Integer self)
    Alias for `getDays(Integer)`.
    Parameters:
      `self` - the number of days
    Returns:
      the corresponding duration

  - ### getHours

    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

  - ### getHour

    public static TimeDuration getHour(Integer self)
    Alias for `getHours(Integer)`.
    Parameters:
      `self` - the number of hours
    Returns:
      the corresponding duration

  - ### getMinutes

    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

  - ### getMinute

    public static TimeDuration getMinute(Integer self)
    Alias for `getMinutes(Integer)`.
    Parameters:
      `self` - the number of minutes
    Returns:
      the corresponding duration

  - ### getSeconds

    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

  - ### getSecond

    public static TimeDuration getSecond(Integer self)
    Alias for `getSeconds(Integer)`.
    Parameters:
      `self` - the number of seconds
    Returns:
      the corresponding duration

  - ### getMilliseconds

    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

  - ### getMillisecond

    public static TimeDuration getMillisecond(Integer self)
    Alias for `getMilliseconds(Integer)`.
    Parameters:
      `self` - the number of milliseconds
    Returns:
      the corresponding duration