public class Duration extends Object implements Serializable
Serializable
duration of time.ExpiryPolicy
,
Serialized FormModifier and Type | Field and Description |
---|---|
static Duration |
ETERNAL
ETERNAL (forever).
|
static Duration |
FIVE_MINUTES
Five minutes.
|
static Duration |
ONE_DAY
One day.
|
static Duration |
ONE_HOUR
One hour.
|
static Duration |
ONE_MINUTE
One minute.
|
static long |
serialVersionUID
The serialVersionUID required for
Serializable . |
static Duration |
TEN_MINUTES
Ten minutes.
|
static Duration |
THIRTY_MINUTES
Thirty minutes.
|
static Duration |
TWENTY_MINUTES
Twenty minutes.
|
static Duration |
ZERO
Zero (no time).
|
Constructor and Description |
---|
Duration()
Constructs a Duration (that by default is Eternal).
|
Duration(long startTime,
long endTime)
Constructs a
Duration based on the duration between two
specified points in time (since the Epoc), measured in milliseconds. |
Duration(TimeUnit timeUnit,
long durationAmount)
Constructs a duration.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other) |
long |
getAdjustedTime(long time)
Calculates the adjusted time (from the Epoc) given a specified time
(to be adjusted) by the duration.
|
long |
getDurationAmount()
Obtain the number of TimeUnits in the Duration
|
TimeUnit |
getTimeUnit()
Obtain the TimeUnit for the Duration
|
int |
hashCode() |
boolean |
isEternal()
Determines if a
Duration is eternal (forever). |
boolean |
isZero()
Determines if a
Duration is zero. |
public static final long serialVersionUID
Serializable
.public static final Duration ETERNAL
public static final Duration ONE_DAY
public static final Duration ONE_HOUR
public static final Duration THIRTY_MINUTES
public static final Duration TWENTY_MINUTES
public static final Duration TEN_MINUTES
public static final Duration FIVE_MINUTES
public static final Duration ONE_MINUTE
public static final Duration ZERO
public Duration()
public Duration(TimeUnit timeUnit, long durationAmount)
timeUnit
- the unit of time to specify time in. The minimum time unit is milliseconds.durationAmount
- how long, in the specified units, the cache entries should live. 0 means eternal.NullPointerException
- if timeUnit is nullIllegalArgumentException
- if durationAmount is less than 0 or a TimeUnit less than milliseconds is specifiedpublic Duration(long startTime, long endTime)
Duration
based on the duration between two
specified points in time (since the Epoc), measured in milliseconds.startTime
- the start time (since the Epoc)endTime
- the end time (since the Epoc)public TimeUnit getTimeUnit()
public long getDurationAmount()
public boolean isEternal()
Duration
is eternal (forever).Duration
is eternalpublic boolean isZero()
Duration
is zero.Duration
is zeropublic long getAdjustedTime(long time)
time
- the time from which to adjust given the durationCopyright © 2014. All Rights Reserved.