Package groovy.time

# Class TimeDuration

java.lang.Object
groovy.time.BaseDuration
groovy.time.Duration
groovy.time.TimeDuration

All Implemented Interfaces:
  `Comparable<BaseDuration>`

@Deprecated public class TimeDuration extends Duration
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.
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.

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class groovy.time.BaseDuration

  `BaseDuration.From`

- ## Field Summary

  ### Fields inherited from class groovy.time.BaseDuration

  `days, hours, millis, minutes, months, seconds, years`

- ## Constructor Summary

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

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Date`
  `getAgo()`
  Deprecated.
  Returns the date represented by this duration ago.
  `BaseDuration.From`
  `getFrom()`
  Deprecated.
  Returns a helper for computing dates relative to now.
  `DatumDependentDuration`
  `minus(DatumDependentDuration rhs)`
  Deprecated.
  Subtracts a datum-dependent duration.
  `Duration`
  `minus(Duration rhs)`
  Deprecated.
  Subtracts a fixed duration.
  `DatumDependentDuration`
  `plus(DatumDependentDuration rhs)`
  Deprecated.
  Adds a datum-dependent duration.
  `Duration`
  `plus(Duration rhs)`
  Deprecated.
  Adds a fixed duration.

  ### Methods inherited from class groovy.time.Duration

  `minus, minus, plus, toMilliseconds`

  ### Methods inherited from class groovy.time.BaseDuration

  `compareTo, getDays, getHours, getMillis, getMinutes, getMonths, getSeconds, getYears, plus, toString`

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

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

- ## Constructor Details

  - ### TimeDuration

    public TimeDuration(int hours, int minutes, int seconds, int millis)
    Deprecated.
    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

  - ### TimeDuration

    public TimeDuration(int days, int hours, int minutes, int seconds, int millis)
    Deprecated.
    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 Details

  - ### plus

    public Duration plus(Duration rhs)
    Deprecated.
    Adds a fixed duration.
    Overrides:
      `plus` in class `Duration`
    Parameters:
      `rhs` - the duration to add
    Returns:
      the combined duration

  - ### plus

    public DatumDependentDuration plus(DatumDependentDuration rhs)
    Deprecated.
    Adds a datum-dependent duration.
    Overrides:
      `plus` in class `Duration`
    Parameters:
      `rhs` - the duration to add
    Returns:
      the combined duration

  - ### minus

    public Duration minus(Duration rhs)
    Deprecated.
    Subtracts a fixed duration.
    Overrides:
      `minus` in class `Duration`
    Parameters:
      `rhs` - the duration to subtract
    Returns:
      the resulting duration

  - ### minus

    public DatumDependentDuration minus(DatumDependentDuration rhs)
    Deprecated.
    Subtracts a datum-dependent duration.
    Overrides:
      `minus` in class `Duration`
    Parameters:
      `rhs` - the duration to subtract
    Returns:
      the resulting duration

  - ### getAgo

    public Date getAgo()
    Deprecated.
    Returns the date represented by this duration ago.
    Overrides:
      `getAgo` in class `Duration`
    Returns:
      the computed date

  - ### getFrom

    public BaseDuration.From getFrom()
    Deprecated.
    Returns a helper for computing dates relative to now.
    Overrides:
      `getFrom` in class `Duration`
    Returns:
      the relative-date helper