Package: groovy.time

## [Java] Class BaseDuration

- groovy.time.BaseDuration

- All Implemented Interfaces and Traits:
    Comparable

      public abstract class BaseDuration
      extends Object
      implements Comparable

  Base class for date and time durations.

  See Also:
    Duration

- - ### Nested Class Summary

    Nested classes
    Modifiers | Name | Description
    --- | --- | ---
    `static class` | `BaseDuration.From` | Helper for computing dates relative to the current time.

  - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `protected int` | `days` | Day component.
    `protected int` | `hours` | Hour component.
    `protected int` | `millis` | Millisecond component.
    `protected int` | `minutes` | Minute component.
    `protected int` | `months` | Month component.
    `protected int` | `seconds` | Second component.
    `protected int` | `years` | Year component.

  - ### Constructor Summary

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

  - ### Methods Summary

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

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### protected final int days

      Day component.

    - #### protected final int hours

      Hour component.

    - #### protected final int millis

      Millisecond component.

    - #### protected final int minutes

      Minute component.

    - #### protected final int months

      Month component.

    - #### protected final int seconds

      Second component.

    - #### protected final int years

      Year component.

  - ### Constructor Detail

    - #### protected BaseDuration(int years, int months, int days, int hours, int minutes, int seconds, int millis)

      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

    - #### protected BaseDuration(int days, int hours, int minutes, int seconds, int millis)

      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 Detail

    - #### public int compareTo(BaseDuration otherDuration)

      Compares this duration with another by their millisecond values.

      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

    - #### public abstract Date getAgo()

      Returns the date represented by this duration ago.

      Returns:
        the computed date

    - #### public int getDays()

      Returns the day component.

      Returns:
        the day component

    - #### public abstract BaseDuration.From getFrom()

      Returns a helper for computing dates relative to now.

      Returns:
        the relative-date helper

    - #### public int getHours()

      Returns the hour component.

      Returns:
        the hour component

    - #### public int getMillis()

      Returns the millisecond component.

      Returns:
        the millisecond component

    - #### public int getMinutes()

      Returns the minute component.

      Returns:
        the minute component

    - #### public int getMonths()

      Returns the month component.

      Returns:
        the month component

    - #### public int getSeconds()

      Returns the second component.

      Returns:
        the second component

    - #### public int getYears()

      Returns the year component.

      Returns:
        the year component

    - #### public Date plus(Date date)

      Adds this duration to the supplied date.

      Parameters:
        `date` - the date to adjust
      Returns:
        the adjusted date

    - #### public abstract long toMilliseconds()

      Converts this duration to milliseconds.

      Returns:
        the duration in milliseconds

    - #### public String toString()

      Returns a human-readable representation of this duration.

      Returns:
        the duration text