Package groovy.time

# Class BaseDuration

java.lang.Object
groovy.time.BaseDuration

All Implemented Interfaces:
  `Comparable<BaseDuration>`

Direct Known Subclasses:
  `DatumDependentDuration`, `Duration`

@Deprecated public abstract class BaseDuration extends Object implements Comparable<BaseDuration>
Deprecated.
Superseded by the quirk-free DSLs: `org.apache.groovy.dateutil.TimeCategory` (and its `java.util.Date`-based duration classes) or `org.apache.groovy.datetime.TimeCategory` (producing `java.time` types). This legacy class is retained, unchanged, for backward compatibility.
Base class for date and time durations.

See Also:
  - `Duration`

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `BaseDuration.From`
  Deprecated.
  Helper for computing dates relative to the current time.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final int`
  `days`
  Deprecated.
  Day component.
  `protected final int`
  `hours`
  Deprecated.
  Hour component.
  `protected final int`
  `millis`
  Deprecated.
  Millisecond component.
  `protected final int`
  `minutes`
  Deprecated.
  Minute component.
  `protected final int`
  `months`
  Deprecated.
  Month component.
  `protected final int`
  `seconds`
  Deprecated.
  Second component.
  `protected final int`
  `years`
  Deprecated.
  Year component.

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `BaseDuration(int days, int hours, int minutes, int seconds, int millis)`
  Deprecated.
  Creates a duration without year or month components.
  `protected`
  `BaseDuration(int years, int months, int days, int hours, int minutes, int seconds, int millis)`
  Deprecated.
  Creates a duration with date and time components.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `compareTo(BaseDuration otherDuration)`
  Deprecated.
  Compares this duration with another by their millisecond values.
  `abstract Date`
  `getAgo()`
  Deprecated.
  Returns the date represented by this duration ago.
  `int`
  `getDays()`
  Deprecated.
  Returns the day component.
  `abstract BaseDuration.From`
  `getFrom()`
  Deprecated.
  Returns a helper for computing dates relative to now.
  `int`
  `getHours()`
  Deprecated.
  Returns the hour component.
  `int`
  `getMillis()`
  Deprecated.
  Returns the millisecond component.
  `int`
  `getMinutes()`
  Deprecated.
  Returns the minute component.
  `int`
  `getMonths()`
  Deprecated.
  Returns the month component.
  `int`
  `getSeconds()`
  Deprecated.
  Returns the second component.
  `int`
  `getYears()`
  Deprecated.
  Returns the year component.
  `Date`
  `plus(Date date)`
  Deprecated.
  Adds this duration to the supplied date.
  `abstract long`
  `toMilliseconds()`
  Deprecated.
  Converts this duration to milliseconds.
  `String`
  `toString()`
  Deprecated.
  Returns a human-readable representation of this duration.

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

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

- ## Field Details

  - ### years

    protected final int years
    Deprecated.
    Year component.

  - ### months

    protected final int months
    Deprecated.
    Month component.

  - ### days

    protected final int days
    Deprecated.
    Day component.

  - ### hours

    protected final int hours
    Deprecated.
    Hour component.

  - ### minutes

    protected final int minutes
    Deprecated.
    Minute component.

  - ### seconds

    protected final int seconds
    Deprecated.
    Second component.

  - ### millis

    protected final int millis
    Deprecated.
    Millisecond component.

- ## Constructor Details

  - ### BaseDuration

    protected BaseDuration(int years, int months, int days, int hours, int minutes, int seconds, int millis)
    Deprecated.
    Creates a duration with date and time components.
    Parameters:
      `years` - the year component
      `months` - the month component
      `days` - the day component
      `hours` - the hour component
      `minutes` - the minute component
      `seconds` - the second component
      `millis` - the millisecond component

  - ### BaseDuration

    protected BaseDuration(int days, int hours, int minutes, int seconds, int millis)
    Deprecated.
    Creates a duration without year or month components.
    Parameters:
      `days` - the day component
      `hours` - the hour component
      `minutes` - the minute component
      `seconds` - the second component
      `millis` - the millisecond component

- ## Method Details

  - ### getYears

    public int getYears()
    Deprecated.
    Returns the year component.
    Returns:
      the year component

  - ### getMonths

    public int getMonths()
    Deprecated.
    Returns the month component.
    Returns:
      the month component

  - ### getDays

    public int getDays()
    Deprecated.
    Returns the day component.
    Returns:
      the day component

  - ### getHours

    public int getHours()
    Deprecated.
    Returns the hour component.
    Returns:
      the hour component

  - ### getMinutes

    public int getMinutes()
    Deprecated.
    Returns the minute component.
    Returns:
      the minute component

  - ### getSeconds

    public int getSeconds()
    Deprecated.
    Returns the second component.
    Returns:
      the second component

  - ### getMillis

    public int getMillis()
    Deprecated.
    Returns the millisecond component.
    Returns:
      the millisecond component

  - ### plus

    public Date plus(Date date)
    Deprecated.
    Adds this duration to the supplied date.
    Parameters:
      `date` - the date to adjust
    Returns:
      the adjusted date

  - ### toString

    public String toString()
    Deprecated.
    Returns a human-readable representation of this duration.
    Overrides:
      `toString` in class `Object`
    Returns:
      the duration text

  - ### toMilliseconds

    public abstract long toMilliseconds()
    Deprecated.
    Converts this duration to milliseconds.
    Returns:
      the duration in milliseconds

  - ### getAgo

    public abstract Date getAgo()
    Deprecated.
    Returns the date represented by this duration ago.
    Returns:
      the computed date

  - ### getFrom

    public abstract BaseDuration.From getFrom()
    Deprecated.
    Returns a helper for computing dates relative to now.
    Returns:
      the relative-date helper

  - ### compareTo

    public int compareTo(BaseDuration otherDuration)
    Deprecated.
    Compares this duration with another by their millisecond values.
    Specified by:
      `compareTo` in interface `Comparable<BaseDuration>`
    Parameters:
      `otherDuration` - the duration to compare against
    Returns:
      a negative, zero, or positive value as this duration is less than, equal to, or greater than the other