Package org.forgerock.util.time
Class Durations
java.lang.Object
org.forgerock.util.time.Durations
Helper class for working with
Duration
objects.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic Duration
Creates aDuration
, given a number and time unit.static Duration
Parses aDuration
from a human-readable string.static boolean
isPositive
(Duration duration) Whether a given duration is positive.static boolean
isUnlimited
(Duration duration) Whether a given duration is considered unlimited.static String
Creates a readable representation of aDuration
.
-
Field Details
-
UNLIMITED
Representation of an unlimited duration.
-
-
Method Details
-
isUnlimited
Whether a given duration is considered unlimited.- Parameters:
duration
- The duration to evaluate.- Returns:
- Whether the duration is unlimited.
-
isPositive
Whether a given duration is positive.- Parameters:
duration
- The duration to evaluate.- Returns:
- Whether the duration is positive.
-
duration
Creates 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
Parses aDuration
from a human-readable string.- Parameters:
value
- The human-readable duration string to parse.- Returns:
- The parsed duration.
-
toString
Creates a readable representation of aDuration
. The method will choose the largest unit that can accurately represent the duration.- Parameters:
duration
- The duration to convert.- Returns:
- The string representation of the duration, in seconds.
-