public abstract class BaseDuration
extends Object
implements Comparable
Base class for date and time durations.
| Modifiers | Name | Description |
|---|---|---|
static class |
BaseDuration.From |
Helper for computing dates relative to the current time. |
| Modifiers | Name | Description |
|---|---|---|
protected int |
days |
Day component. |
protected int |
hours |
Hour component. |
protected int |
millis |
Millisecond component. |
protected int |
minutes |
Minute component. |
protected int |
months |
Month component. |
protected int |
seconds |
Second component. |
protected int |
years |
Year component. |
| Constructor and description |
|---|
protected BaseDuration(int years, int months, int days, int hours, int minutes, int seconds, int millis)Creates a duration with date and time components. |
protected BaseDuration(int days, int hours, int minutes, int seconds, int millis)Creates a duration without year or month components. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public int |
compareTo(BaseDuration otherDuration)Compares this duration with another by their millisecond values. |
|
public abstract Date |
getAgo()Returns the date represented by this duration ago. |
|
public int |
getDays()Returns the day component. |
|
public abstract BaseDuration.From |
getFrom()Returns a helper for computing dates relative to now. |
|
public int |
getHours()Returns the hour component. |
|
public int |
getMillis()Returns the millisecond component. |
|
public int |
getMinutes()Returns the minute component. |
|
public int |
getMonths()Returns the month component. |
|
public int |
getSeconds()Returns the second component. |
|
public int |
getYears()Returns the year component. |
|
public Date |
plus(Date date)Adds this duration to the supplied date. |
|
public abstract long |
toMilliseconds()Converts this duration to milliseconds. |
|
public String |
toString()Returns a human-readable representation of this duration. |
Day component.
Hour component.
Millisecond component.
Minute component.
Month component.
Second component.
Year component.
Creates a duration with date and time components.
years - the year componentmonths - the month componentdays - the day componenthours - the hour componentminutes - the minute componentseconds - the second componentmillis - the millisecond componentCreates a duration without year or month components.
days - the day componenthours - the hour componentminutes - the minute componentseconds - the second componentmillis - the millisecond componentCompares this duration with another by their millisecond values.
otherDuration - the duration to compare againstReturns the date represented by this duration ago.
Returns the day component.
Returns a helper for computing dates relative to now.
Returns the hour component.
Returns the millisecond component.
Returns the minute component.
Returns the month component.
Returns the second component.
Returns the year component.
Adds this duration to the supplied date.
date - the date to adjustConverts this duration to milliseconds.
Returns a human-readable representation of this duration.
Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.