Package groovy.time
Class DatumDependentDuration
java.lang.Object
groovy.time.BaseDuration
groovy.time.DatumDependentDuration
- All Implemented Interfaces:
Comparable<BaseDuration>
- Direct Known Subclasses:
TimeDatumDependentDuration
DatumDependentDuration represents durations whose length in milliseconds
cannot be determined without knowing the datum point.
I don't know how many days in a year unless I know if it's a leap year or not.
I don't know how many days in a month unless I know the name of the month (and if it's a leap year if the month is February)
-
Nested Class Summary
Nested classes/interfaces inherited from class groovy.time.BaseDuration
BaseDuration.From -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionDatumDependentDuration(int years, int months, int days, int hours, int minutes, int seconds, int millis) Creates a datum-dependent duration. -
Method Summary
Modifier and TypeMethodDescriptiongetAgo()Returns the date represented by this duration ago.getFrom()Returns a helper for computing dates relative to now.intReturns the month component.intgetYears()Returns the year component.Subtracts another datum-dependent duration.Subtracts a fixed duration.Adds another datum-dependent duration.Adds a fixed duration.Adds a mixed time and datum-dependent duration.plus(TimeDuration rhs) Adds a time duration.longConverts this duration to milliseconds.Methods inherited from class groovy.time.BaseDuration
compareTo, getDays, getHours, getMillis, getMinutes, getSeconds, plus, toString
-
Constructor Details
-
DatumDependentDuration
public DatumDependentDuration(int years, int months, int days, int hours, int minutes, int seconds, int millis) Creates a datum-dependent duration.- Parameters:
years- the year componentmonths- the month componentdays- the day componenthours- the hour componentminutes- the minute componentseconds- the second componentmillis- the millisecond component
-
-
Method Details
-
getMonths
public int getMonths()Returns the month component.- Overrides:
getMonthsin classBaseDuration- Returns:
- the month component
-
getYears
public int getYears()Returns the year component.- Overrides:
getYearsin classBaseDuration- Returns:
- the year component
-
plus
Adds another datum-dependent duration.- Parameters:
rhs- the duration to add- Returns:
- the combined duration
-
plus
Adds a mixed time and datum-dependent duration.- Parameters:
rhs- the duration to add- Returns:
- the combined duration
-
plus
Adds a fixed duration.- Parameters:
rhs- the duration to add- Returns:
- the combined duration
-
plus
Adds a time duration.- Parameters:
rhs- the duration to add- Returns:
- the combined duration
-
minus
Subtracts another datum-dependent duration.- Parameters:
rhs- the duration to subtract- Returns:
- the resulting duration
-
minus
Subtracts a fixed duration.- Parameters:
rhs- the duration to subtract- Returns:
- the resulting duration
-
toMilliseconds
public long toMilliseconds()Description copied from class:BaseDurationConverts this duration to milliseconds.- Specified by:
toMillisecondsin classBaseDuration- Returns:
- the duration in milliseconds
- See Also:
-
getAgo
Returns the date represented by this duration ago.- Specified by:
getAgoin classBaseDuration- Returns:
- the computed date
-
getFrom
Returns a helper for computing dates relative to now.- Specified by:
getFromin classBaseDuration- Returns:
- the relative-date helper
-