@Deprecated
public class TimeDuration
extends Duration
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.
org.apache.groovy.dateutil.TimeDuration (the dequirked
java.util.Date flavor) or java.time.Duration. This legacy class is retained,
unchanged, for backward compatibility.| Constructor and description |
|---|
TimeDuration(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. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public Date |
getAgo()Returns the date represented by this duration ago. |
|
public From |
getFrom()Returns a helper for computing dates relative to now. |
|
public Duration |
minus(Duration rhs)Subtracts a fixed duration. |
|
public DatumDependentDuration |
minus(DatumDependentDuration rhs)Subtracts a datum-dependent duration. |
|
public Duration |
plus(Duration rhs)Adds a fixed duration. |
|
public DatumDependentDuration |
plus(DatumDependentDuration rhs)Adds a datum-dependent duration. |
| Methods inherited from class | Name |
|---|---|
class Duration |
getAgo, getFrom, minus, minus, minus, minus, plus, plus, plus, toMilliseconds |
class BaseDuration |
compareTo, getAgo, getDays, getFrom, getHours, getMillis, getMinutes, getMonths, getSeconds, getYears, plus, toMilliseconds, toString |
Creates a time duration without a day component.
hours - the hour componentminutes - the minute componentseconds - the second componentmillis - the millisecond componentCreates a time duration with an optional day component.
days - the day componenthours - the hour componentminutes - the minute componentseconds - the second componentmillis - the millisecond componentReturns the date represented by this duration ago.
Returns a helper for computing dates relative to now.
Subtracts a fixed duration.
rhs - the duration to subtractSubtracts a datum-dependent duration.
rhs - the duration to subtractAdds a fixed duration.
rhs - the duration to addAdds a datum-dependent duration.
rhs - the duration to addCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.