Package: org.apache.groovy.datetime

## [Java] Class TimeCategory

- org.apache.groovy.datetime.TimeCategory

-     public class TimeCategory
      extends Object

  A `java.time`-based DSL for convenient date/time manipulation, the modern counterpart to the legacy `groovy.time.TimeCategory`. Numbers gain properties that produce Duration (time-based amounts) or Period (date-based amounts), which compose with the `java.time` types via their native arithmetic:

       import java.time.LocalDate
       import java.time.LocalDateTime
       use (org.apache.groovy.datetime.TimeCategory) {
           assert LocalDate.of(2000, 1, 1) + 2.months == LocalDate.of(2000, 3, 1)
           assert 2.days.ago instanceof LocalDate
           assert 1.hour.from.now instanceof LocalDateTime
       }

  Time-based units (`nanoseconds`, `milliseconds`, `seconds`, `minutes`, `hours`) yield a Duration; date-based units (`days`, `weeks`, `months`, `years`) yield a Period. The two are not combined into a single amount (as `java.time` intends); instead they compose by chaining, e.g. `someDateTime + 2.months + 3.hours`.

  Unlike the legacy DSL, `.ago`/`.from.now` never floor the time-of-day: a Duration resolves against LocalDateTime.now (time preserved) and a Period against LocalDate.now (date only, so no time component exists).

- - ### Nested Class Summary

    Nested classes
    Modifiers | Name | Description
    --- | --- | ---
    `static class` | `TimeCategory.From` | Helper returned by getFrom, supporting the `.now` / `.today` suffix.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static LocalDateTime` | `getAgo(Duration self)` The LocalDateTime this time-based duration before now (time-of-day preserved).
    `` | `public static LocalDate` | `getAgo(Period self)` The LocalDate this date-based period before today.
    `` | `public static Period` | `getDay(Integer self)`
    `` | `public static Period` | `getDays(Integer self)`
    `` | `public static TimeCategory.From` | `getFrom(Duration self)` Helper for `duration.from.now`; the resulting temporal is a LocalDateTime.
    `` | `public static TimeCategory.From` | `getFrom(Period self)` Helper for `period.from.now`; the resulting temporal is a LocalDate.
    `` | `public static Duration` | `getHour(Integer self)`
    `` | `public static Duration` | `getHours(Integer self)`
    `` | `public static Duration` | `getMillisecond(Integer self)`
    `` | `public static Duration` | `getMilliseconds(Integer self)`
    `` | `public static Duration` | `getMinute(Integer self)`
    `` | `public static Duration` | `getMinutes(Integer self)`
    `` | `public static Period` | `getMonth(Integer self)`
    `` | `public static Period` | `getMonths(Integer self)`
    `` | `public static Duration` | `getNanosecond(Integer self)`
    `` | `public static Duration` | `getNanoseconds(Integer self)`
    `` | `public static Duration` | `getSecond(Integer self)`
    `` | `public static Duration` | `getSeconds(Integer self)`
    `` | `public static Period` | `getWeek(Integer self)`
    `` | `public static Period` | `getWeeks(Integer self)`
    `` | `public static Period` | `getYear(Integer self)`
    `` | `public static Period` | `getYears(Integer self)`

  - ### 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 LocalDateTime getAgo(Duration self)

      The LocalDateTime this time-based duration before now (time-of-day preserved).

    - #### public static LocalDate getAgo(Period self)

      The LocalDate this date-based period before today.

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

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

    - #### public static TimeCategory.From getFrom(Duration self)

      Helper for `duration.from.now`; the resulting temporal is a LocalDateTime.

    - #### public static TimeCategory.From getFrom(Period self)

      Helper for `period.from.now`; the resulting temporal is a LocalDate.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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