Duration (Groovy 2.4.6)
Date: 2016-02-18

groovy.time

## Class Duration

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

- All Implemented Interfaces:
    Comparable<BaseDuration>
  Direct Known Subclasses:
    TimeDuration

      public class Duration
      extends BaseDuration

  Duration represents time periods which have values independent of the context. So, 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 day is independent of the date.

  This is not 100% true for days. Days can actually be 23, 24 or 25 hours long (due to daylight saving adjustments.)

  If you ask Duration to convert itself to milliseconds then it will work on the basis of 24 hours in a day. If you add or subtract it from a date it will take daylight saving into account.

  Author:
    John Wilson tug@wilson.co.uk

- - ### 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 and Description
    `Duration(int days, int hours, int minutes, int seconds, int millis)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Date` | `getAgo()`
    `BaseDuration.From` | `getFrom()`
    `DatumDependentDuration` | `minus(DatumDependentDuration rhs)`
    `Duration` | `minus(Duration rhs)`
    `TimeDatumDependentDuration` | `minus(TimeDatumDependentDuration rhs)`
    `TimeDuration` | `minus(TimeDuration rhs)`
    `DatumDependentDuration` | `plus(DatumDependentDuration rhs)`
    `Duration` | `plus(Duration rhs)`
    `Duration` | `plus(TimeDuration rhs)`
    `long` | `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 Detail

    - #### Duration

          public Duration(int days,
                  int hours,
                  int minutes,
                  int seconds,
                  int millis)

  - ### Method Detail

    - #### plus

          public Duration plus(Duration rhs)

    - #### plus

          public Duration plus(TimeDuration rhs)

    - #### plus

          public DatumDependentDuration plus(DatumDependentDuration rhs)

    - #### minus

          public Duration minus(Duration rhs)

    - #### minus

          public TimeDuration minus(TimeDuration rhs)

    - #### minus

          public DatumDependentDuration minus(DatumDependentDuration rhs)

    - #### minus

          public TimeDatumDependentDuration minus(TimeDatumDependentDuration rhs)

    - #### toMilliseconds

          public long toMilliseconds()

      Specified by:
        `toMilliseconds` in class `BaseDuration`

    - #### getAgo

          public Date getAgo()

      Specified by:
        `getAgo` in class `BaseDuration`

    - #### getFrom

          public BaseDuration.From getFrom()

      Specified by:
        `getFrom` in class `BaseDuration`