Package org.apache.groovy.dateutil
Class Duration
java.lang.Object
org.apache.groovy.dateutil.BaseDuration
org.apache.groovy.dateutil.Duration
- All Implemented Interfaces:
Comparable<BaseDuration>
- Direct Known Subclasses:
TimeDuration
A context-independent duration: days and below, whose length is known without a datum.
DEQUIRKED: toMilliseconds(), getAgo() and getFrom() are now
inherited from BaseDuration (uniform, deterministic, time-preserving); only the
type-preserving arithmetic remains here.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.groovy.dateutil.BaseDuration
BaseDuration.From -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionDuration(int days, int hours, int minutes, int seconds, int millis) Stores the day and time components. -
Method Summary
Modifier and TypeMethodDescriptionSubtractsrhs.Subtracts each day and time component ofrhs.Subtractsrhs.minus(TimeDuration rhs) Subtracts each day and time component ofrhsand returns aTimeDuration.Adds this duration torhsby callingrhs.plus(this).Adds each day and time component ofrhs.plus(TimeDuration rhs) Adds this duration torhsby callingrhs.plus(this), so the result is aTimeDuration.Methods inherited from class org.apache.groovy.dateutil.BaseDuration
compareTo, getAgo, getDays, getFrom, getHours, getMillis, getMinutes, getMonths, getSeconds, getYears, plus, toMilliseconds, toString
-
Constructor Details
-
Duration
public Duration(int days, int hours, int minutes, int seconds, int millis) Stores the day and time components. Years and months stay zero.- Parameters:
days- whole dayshours- hoursminutes- minutesseconds- secondsmillis- milliseconds
-
-
Method Details
-
plus
Adds each day and time component ofrhs. The components are not normalized.- Parameters:
rhs- duration to add- Returns:
- the component-wise sum
-
plus
Adds this duration torhsby callingrhs.plus(this), so the result is aTimeDuration.- Parameters:
rhs- duration to add- Returns:
- the sum, typed as
rhscomputes it
-
plus
Adds this duration torhsby callingrhs.plus(this). Years and months stay those ofrhs; the day and time components are added.- Parameters:
rhs- duration to add- Returns:
- the sum, typed as
rhscomputes it
-
minus
Subtracts each day and time component ofrhs. The components are not normalized.- Parameters:
rhs- duration to subtract- Returns:
- the component-wise difference
-
minus
Subtracts each day and time component ofrhsand returns aTimeDuration. The components are not normalized.- Parameters:
rhs- duration to subtract- Returns:
- the component-wise difference
-
minus
Subtractsrhs. Years and months ofrhsare negated, and the day and time components are subtracted. The result is aDatumDependentDuration.- Parameters:
rhs- duration to subtract- Returns:
- the component-wise difference
-
minus
Subtractsrhs. Years and months ofrhsare negated, and the day and time components are subtracted. The result is aTimeDatumDependentDuration.- Parameters:
rhs- duration to subtract- Returns:
- the component-wise difference
-