Package groovy.time
Class Duration
java.lang.Object
groovy.time.BaseDuration
groovy.time.Duration
- All Implemented Interfaces:
Comparable<BaseDuration>
- Direct Known Subclasses:
TimeDuration
Deprecated.
Duration represents time periods which have values independent of the context.
So, 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 day is independent of the date.
This is not 100% true for days. Days can actually be 23, 24 or 25 hours long (due to daylight saving adjustments.)
If you ask Duration to convert itself to milliseconds then it will work on the basis of 24 hours in a day. If you add or subtract it from a date it will take daylight saving into account.
-
Nested Class Summary
Nested classes/interfaces inherited from class groovy.time.BaseDuration
BaseDuration.From -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionDuration(int days, int hours, int minutes, int seconds, int millis) Deprecated.Creates a fixed duration. -
Method Summary
Modifier and TypeMethodDescriptiongetAgo()Deprecated.Returns the date represented by this duration ago.getFrom()Deprecated.Returns a helper for computing dates relative to now.Deprecated.Subtracts a datum-dependent duration.Deprecated.Subtracts another fixed duration.Deprecated.Subtracts a mixed time and datum-dependent duration.minus(TimeDuration rhs) Deprecated.Subtracts a time duration.Deprecated.Adds a datum-dependent duration.Deprecated.Adds another fixed duration.plus(TimeDuration rhs) Deprecated.Adds a time duration.longDeprecated.Converts this duration to milliseconds assuming 24-hour days.Methods inherited from class groovy.time.BaseDuration
compareTo, getDays, getHours, getMillis, getMinutes, getMonths, getSeconds, getYears, plus, toString
-
Constructor Details
-
Duration
public Duration(int days, int hours, int minutes, int seconds, int millis) Deprecated.Creates a fixed duration.- Parameters:
days- the day componenthours- the hour componentminutes- the minute componentseconds- the second componentmillis- the millisecond component
-
-
Method Details
-
plus
Deprecated.Adds another fixed duration.- Parameters:
rhs- the duration to add- Returns:
- the combined duration
-
plus
Deprecated.Adds a time duration.- Parameters:
rhs- the duration to add- Returns:
- the combined duration
-
plus
Deprecated.Adds a datum-dependent duration.- Parameters:
rhs- the duration to add- Returns:
- the combined duration
-
minus
Deprecated.Subtracts another fixed duration.- Parameters:
rhs- the duration to subtract- Returns:
- the resulting duration
-
minus
Deprecated.Subtracts a time duration.- Parameters:
rhs- the duration to subtract- Returns:
- the resulting duration
-
minus
Deprecated.Subtracts a datum-dependent duration.- Parameters:
rhs- the duration to subtract- Returns:
- the resulting duration
-
minus
Deprecated.Subtracts a mixed time and datum-dependent duration.- Parameters:
rhs- the duration to subtract- Returns:
- the resulting duration
-
toMilliseconds
public long toMilliseconds()Deprecated.Converts this duration to milliseconds assuming 24-hour days.- Specified by:
toMillisecondsin classBaseDuration- Returns:
- the duration in milliseconds
-
getAgo
Deprecated.Returns the date represented by this duration ago.- Specified by:
getAgoin classBaseDuration- Returns:
- the computed date
-
getFrom
Deprecated.Returns a helper for computing dates relative to now.- Specified by:
getFromin classBaseDuration- Returns:
- the relative-date helper
-
org.apache.groovy.dateutil.Duration(the dequirkedjava.util.Dateflavor) orjava.time.Duration/java.time.Period. This legacy class is retained, unchanged, for backward compatibility.