public abstract class BaseDuration
extends Object
implements Comparable
Base class for date and time durations (dequirked, java.util.Date-flavored).
This is the B1 prototype: the same value-class model as the legacy
groovy.time.BaseDuration, but with the historical quirks removed:
new Date() ("now"), so the result no longer depends on when it is called.| Modifiers | Name | Description |
|---|---|---|
static class |
BaseDuration.From |
Helper for computing dates relative to the current time. |
| Constructor and description |
|---|
protected BaseDuration(int years, int months, int days, int hours, int minutes, int seconds, int millis) |
protected BaseDuration(int days, int hours, int minutes, int seconds, int millis) |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public int |
compareTo(BaseDuration other) |
|
public Date |
getAgo()The date this duration ago. |
|
public int |
getDays() |
|
public BaseDuration.From |
getFrom()Helper for computing dates relative to the current time. |
|
public int |
getHours() |
|
public int |
getMillis() |
|
public int |
getMinutes() |
|
public int |
getMonths() |
|
public int |
getSeconds() |
|
public int |
getYears() |
|
public Date |
plus(Date date)Adds this duration to the supplied date. |
|
public long |
toMilliseconds()Converts this duration to milliseconds. |
|
public String |
toString() |
The date this duration ago.
DEQUIRKED (A): the time-of-day is preserved (no flooring to midnight), uniformly for all duration kinds.
Helper for computing dates relative to the current time. DEQUIRKED (A): time-of-day preserved.
Converts this duration to milliseconds.
DEQUIRKED (B): deterministic. Years and months use ChronoUnit estimates
(a year is exactly 12 estimated months, so 1.year == 12.months); days and
below are exact assuming 24-hour days. The result never depends on the current date.
Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.