Class DatumDependentDuration

java.lang.Object
org.apache.groovy.dateutil.BaseDuration
org.apache.groovy.dateutil.DatumDependentDuration
All Implemented Interfaces:
Comparable<BaseDuration>
Direct Known Subclasses:
TimeDatumDependentDuration

public class DatumDependentDuration extends BaseDuration
A duration that includes years and/or months, whose exact length depends on the datum.

DEQUIRKED: toMilliseconds() is now deterministic (see BaseDuration); it no longer resolves against "now". getAgo()/getFrom() are inherited and no longer zero the time-of-day.

  • Constructor Details

    • DatumDependentDuration

      public DatumDependentDuration(int years, int months, int days, int hours, int minutes, int seconds, int millis)
      Stores years, months, and the day and time components.
      Parameters:
      years - whole years
      months - whole months
      days - whole days
      hours - hours
      minutes - minutes
      seconds - seconds
      millis - milliseconds
  • Method Details

    • plus

      Adds every component of rhs, including years and months. The components are not normalized.
      Parameters:
      rhs - duration to add
      Returns:
      the component-wise sum
    • plus

      Adds this duration to rhs by calling rhs.plus(this), so the result is a TimeDatumDependentDuration.
      Parameters:
      rhs - duration to add
      Returns:
      the sum, typed as rhs computes it
    • plus

      public DatumDependentDuration plus(Duration rhs)
      Adds the day and time components of rhs. Years and months stay those of this duration. The components are not normalized.
      Parameters:
      rhs - duration to add
      Returns:
      the component-wise sum
    • plus

      Adds this duration to rhs by calling rhs.plus(this). TimeDuration.plus returns a TimeDatumDependentDuration.
      Parameters:
      rhs - duration to add
      Returns:
      the sum, typed as rhs computes it
    • minus

      Subtracts every component of rhs, including years and months. The components are not normalized.
      Parameters:
      rhs - duration to subtract
      Returns:
      the component-wise difference
    • minus

      public DatumDependentDuration minus(Duration rhs)
      Subtracts the day and time components of rhs. Years and months stay those of this duration. The components are not normalized.
      Parameters:
      rhs - duration to subtract
      Returns:
      the component-wise difference