Package: groovy.time

## [Java] Class TimeDuration

- groovy.time.TimeDuration

-     @Deprecated
      public class TimeDuration
      extends Duration

  TimeDuration represents time periods expressed in units of hours, minutes, seconds and milliseconds.

  Whilst we can't say how long a month is without knowing the year and the name of the month, we know how long a second is independent of the date.

  This is not 100% true for minutes. Minutes can be 59, 60 or 61 seconds long (due to leap seconds.)

  If you ask Duration to convert itself to milliseconds then it will work on the basis of 60 seconds in a minute. If you add or subtract it from a date it will take leap seconds into account.

  deprecated:
    Superseded by `org.apache.groovy.dateutil.TimeDuration` (the dequirked `java.util.Date` flavor) or `java.time.Duration`. This legacy class is retained, unchanged, for backward compatibility.

- - Inherited fields
    Fields inherited from class | Fields
    --- | ---
    `class BaseDuration` | `days, hours, millis, minutes, months, seconds, years`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `TimeDuration(int hours, int minutes, int seconds, int millis)` Creates a time duration without a day component.
    `TimeDuration(int days, int hours, int minutes, int seconds, int millis)` Creates a time duration with an optional day component.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public Date` | `getAgo()` Returns the date represented by this duration ago.
    `` | `public From` | `getFrom()` Returns a helper for computing dates relative to now.
    `` | `public Duration` | `minus(Duration rhs)` Subtracts a fixed duration.
    `` | `public DatumDependentDuration` | `minus(DatumDependentDuration rhs)` Subtracts a datum-dependent duration.
    `` | `public Duration` | `plus(Duration rhs)` Adds a fixed duration.
    `` | `public DatumDependentDuration` | `plus(DatumDependentDuration rhs)` Adds a datum-dependent duration.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Duration` | `getAgo, getFrom, minus, minus, minus, minus, plus, plus, plus, toMilliseconds`
    `class BaseDuration` | `compareTo, getAgo, getDays, getFrom, getHours, getMillis, getMinutes, getMonths, getSeconds, getYears, plus, toMilliseconds, toString`

- - ### Constructor Detail

    - #### public TimeDuration(int hours, int minutes, int seconds, int millis)

      Creates a time duration without a day component.

      Parameters:
        `hours` - the hour component
        `minutes` - the minute component
        `seconds` - the second component
        `millis` - the millisecond component

    - #### public TimeDuration(int days, int hours, int minutes, int seconds, int millis)

      Creates a time duration with an optional day component.

      Parameters:
        `days` - the day component
        `hours` - the hour component
        `minutes` - the minute component
        `seconds` - the second component
        `millis` - the millisecond component

  - ### Method Detail

    - #### public Date getAgo()

      Returns the date represented by this duration ago.

      Returns:
        the computed date

    - #### public From getFrom()

      Returns a helper for computing dates relative to now.

      Returns:
        the relative-date helper

    - #### public Duration minus(Duration rhs)

      Subtracts a fixed duration.

      Parameters:
        `rhs` - the duration to subtract
      Returns:
        the resulting duration

    - #### public DatumDependentDuration minus(DatumDependentDuration rhs)

      Subtracts a datum-dependent duration.

      Parameters:
        `rhs` - the duration to subtract
      Returns:
        the resulting duration

    - #### public Duration plus(Duration rhs)

      Adds a fixed duration.

      Parameters:
        `rhs` - the duration to add
      Returns:
        the combined duration

    - #### public DatumDependentDuration plus(DatumDependentDuration rhs)

      Adds a datum-dependent duration.

      Parameters:
        `rhs` - the duration to add
      Returns:
        the combined duration