Package org.forgerock.util.time
Class Duration
java.lang.Object
org.forgerock.util.time.Duration
- All Implemented Interfaces:
Comparable<Duration>
@Deprecated(since="27.0.0",
forRemoval=true)
public class Duration
extends Object
implements Comparable<Duration>
Deprecated, for removal: This API element is subject to removal in a future version.
Represents a duration in english. Cases is not important, plurals units are accepted.
Notice that negative durations are not supported.
6 days
59 minutes and 1 millisecond
1 minute and 10 seconds
42 millis
unlimited
none
zero
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Duration
Deprecated, for removal: This API element is subject to removal in a future version.Special duration that represents an unlimited duration (or indefinite).static final Duration
Deprecated, for removal: This API element is subject to removal in a future version.Special duration that represents a zero-length duration. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.Convert the current duration to a givenTimeUnit
.static Duration
Deprecated, for removal: This API element is subject to removal in a future version.Provides aDuration
, given a number and time unit.static Duration
Deprecated, for removal: This API element is subject to removal in a future version.Provides aDuration
that represents the given duration expressed in english.boolean
Deprecated, for removal: This API element is subject to removal in a future version.static Duration
fromJavaDuration
(Duration duration) Deprecated, for removal: This API element is subject to removal in a future version.Creates a Duration instance from a JavaDuration
.getUnit()
Deprecated, for removal: This API element is subject to removal in a future version.Returns theTimeUnit
this duration is expressed in.long
getValue()
Deprecated, for removal: This API element is subject to removal in a future version.Returns the number ofTimeUnit
this duration represents.int
hashCode()
Deprecated, for removal: This API element is subject to removal in a future version.boolean
Deprecated, for removal: This API element is subject to removal in a future version.Returns true if this Duration represents an unlimited (or indefinite) duration.boolean
isZero()
Deprecated, for removal: This API element is subject to removal in a future version.Returns true if this Duration represents a zero-length duration.long
Deprecated, for removal: This API element is subject to removal in a future version.Convert the current duration to a number of givenTimeUnit
.Deprecated, for removal: This API element is subject to removal in a future version.Returns this duration as a JavaDuration
.toString()
Deprecated, for removal: This API element is subject to removal in a future version.
-
Field Details
-
UNLIMITED
Deprecated, for removal: This API element is subject to removal in a future version.Special duration that represents an unlimited duration (or indefinite). -
ZERO
Deprecated, for removal: This API element is subject to removal in a future version.Special duration that represents a zero-length duration.
-
-
Constructor Details
-
Duration
Deprecated.Prefer the use ofduration(long, TimeUnit)
.Builds a newDuration
.- Parameters:
number
- number of time unit (cannot be null).unit
- TimeUnit to express the duration in (cannot be null).
-
-
Method Details
-
duration
Deprecated, for removal: This API element is subject to removal in a future version.Provides aDuration
, given a number and time unit.- Parameters:
number
- number of time unit.unit
- TimeUnit to express the duration in (cannot be null).- Returns:
Duration
instance
-
duration
Deprecated, for removal: This API element is subject to removal in a future version.Provides aDuration
that represents the given duration expressed in english.- Parameters:
value
- natural speech duration- Returns:
Duration
instance- Throws:
IllegalArgumentException
- if the input string is incorrectly formatted.
-
getValue
public long getValue()Deprecated, for removal: This API element is subject to removal in a future version.Returns the number ofTimeUnit
this duration represents.- Returns:
- the number of
TimeUnit
this duration represents
-
toJavaDuration
Deprecated, for removal: This API element is subject to removal in a future version.Returns this duration as a JavaDuration
.- Returns:
- a new equivalent Java Duration
-
fromJavaDuration
Deprecated, for removal: This API element is subject to removal in a future version.Creates a Duration instance from a JavaDuration
.- Parameters:
duration
- the Java Duration to convert- Returns:
- a new equivalent Duration
-
getUnit
Deprecated, for removal: This API element is subject to removal in a future version.Returns theTimeUnit
this duration is expressed in.- Returns:
- the
TimeUnit
this duration is expressed in.
-
convertTo
Deprecated, for removal: This API element is subject to removal in a future version.Convert the current duration to a givenTimeUnit
. Conversions from finer to coarser granularities truncate, so loose precision.- Parameters:
targetUnit
- target unit of the conversion.- Returns:
- converted duration
- See Also:
-
to
Deprecated, for removal: This API element is subject to removal in a future version.Convert the current duration to a number of givenTimeUnit
. Conversions from finer to coarser granularities truncate, so loose precision.- Parameters:
targetUnit
- target unit of the conversion.- Returns:
- converted duration value
- See Also:
-
isUnlimited
public boolean isUnlimited()Deprecated, for removal: This API element is subject to removal in a future version.Returns true if this Duration represents an unlimited (or indefinite) duration.- Returns:
- true if this Duration represents an unlimited duration.
-
isZero
public boolean isZero()Deprecated, for removal: This API element is subject to removal in a future version.Returns true if this Duration represents a zero-length duration.- Returns:
- true if this Duration represents a zero-length duration
-
toString
Deprecated, for removal: This API element is subject to removal in a future version. -
compareTo
Deprecated, for removal: This API element is subject to removal in a future version.- Specified by:
compareTo
in interfaceComparable<Duration>
-
equals
Deprecated, for removal: This API element is subject to removal in a future version. -
hashCode
public int hashCode()Deprecated, for removal: This API element is subject to removal in a future version.
-
Duration
instead.