Package groovy.time
Class TimeDuration
java.lang.Object
groovy.time.BaseDuration
groovy.time.Duration
groovy.time.TimeDuration
- All Implemented Interfaces:
Comparable<BaseDuration>
TimeDuration represents time periods expressed in units of hours, minutes,
seconds and milliseconds.
Whilst we can't say how long a month is without knowing the year and the name of the month, we know how long a second is independent of the date.
This is not 100% true for minutes. Minutes can be 59, 60 or 61 seconds long (due to leap seconds.)
If you ask Duration to convert itself to milliseconds then it will work on the basis of 60 seconds in a minute. If you add or subtract it from a date it will take leap seconds into account.
-
Nested Class Summary
Nested classes/interfaces inherited from class groovy.time.BaseDuration
BaseDuration.From -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionTimeDuration(int hours, int minutes, int seconds, int millis) Creates a time duration without a day component.TimeDuration(int days, int hours, int minutes, int seconds, int millis) Creates a time duration with an optional day component. -
Method Summary
Methods inherited from class groovy.time.Duration
minus, minus, plus, toMillisecondsMethods inherited from class groovy.time.BaseDuration
compareTo, getDays, getHours, getMillis, getMinutes, getMonths, getSeconds, getYears, plus, toString
-
Constructor Details
-
TimeDuration
public TimeDuration(int hours, int minutes, int seconds, int millis) Creates a time duration without a day component.- Parameters:
hours- the hour componentminutes- the minute componentseconds- the second componentmillis- the millisecond component
-
TimeDuration
public TimeDuration(int days, int hours, int minutes, int seconds, int millis) Creates a time duration with an optional day component.- Parameters:
days- the day componenthours- the hour componentminutes- the minute componentseconds- the second componentmillis- the millisecond component
-
-
Method Details
-
plus
Adds a fixed duration. -
plus
Adds a datum-dependent duration. -
minus
Subtracts a fixed duration. -
minus
Subtracts a datum-dependent duration. -
getAgo
Returns the date represented by this duration ago. -
getFrom
Returns a helper for computing dates relative to now.
-