public final class Duration
extends java.lang.Object
TimeUnit
.Modifier and Type | Field and Description |
---|---|
static Duration |
INFINITE
The infinite
Duration . |
static Duration |
ZERO
The zero
Duration . |
Constructor and Description |
---|
Duration(long length,
java.util.concurrent.TimeUnit timeUnit)
Instantiates a new
Duration of the given length and TimeUnit . |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
long |
getLength()
Gets the length of time this
Duration represents. |
java.util.concurrent.TimeUnit |
getTimeUnit()
Gets the
TimeUnit of this Duration . |
int |
hashCode() |
boolean |
isInfinite()
Indicates if this duration represents
INFINITE or an infinite Duration . |
java.lang.String |
toString() |
public static final Duration INFINITE
Duration
.
This constant should be used to express a lack of a concrete expiration time (ie. "eternal").
public static final Duration ZERO
Duration
.public Duration(long length, java.util.concurrent.TimeUnit timeUnit)
Duration
of the given length and TimeUnit
.length
- the duration lengthtimeUnit
- the time unitjava.lang.NullPointerException
- if the given time unit is nulljava.lang.IllegalArgumentException
- if the given length is less than zeropublic long getLength()
Duration
represents.java.lang.IllegalStateException
- if this instance is INFINITE
getTimeUnit()
public java.util.concurrent.TimeUnit getTimeUnit()
TimeUnit
of this Duration
.TimeUnit
of this instancejava.lang.IllegalStateException
- if this instance is INFINITE
getLength()
public boolean isInfinite()
INFINITE
or an infinite Duration
.true
if this instance is the special Forever
valuepublic int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object