Package org.moeaframework.util
Class DurationUtils
java.lang.Object
org.moeaframework.util.DurationUtils
Utility for converting a
Duration
into primitives.-
Method Summary
Modifier and TypeMethodDescriptionstatic final String
Produces a ISO 8601 duration format in the formhh:mm:ss
.static final String
formatHighResolution
(Duration duration) Produces a higher-resolution format string in the formss.mmmm "s"
.static final boolean
isGreaterThanOrEqual
(Duration lhs, Duration rhs) Returnstrue
if the left-hand side is greater than or equal to the right-hand side duration.static final long
toMilliseconds
(Duration duration) Converts the given duration into milliseconds.static final long
toNanoseconds
(Duration duration) Converts the given duration into nanoseconds.static final double
toPercentage
(Duration elapsed, Duration total) Returns the percentage as a value between0.0
and100.0
showing the percent complete.static final double
Converts the given duration into fractional seconds.
-
Method Details
-
isGreaterThanOrEqual
Returnstrue
if the left-hand side is greater than or equal to the right-hand side duration.- Parameters:
lhs
- the left-hand siderhs
- the right-hand side- Returns:
true
if greater than or equal;false
otherwise
-
toPercentage
Returns the percentage as a value between0.0
and100.0
showing the percent complete.- Parameters:
elapsed
- the elasped timetotal
- the total time- Returns:
- the percentage
-
toSeconds
Converts the given duration into fractional seconds.- Parameters:
duration
- the duration- Returns:
- the duration in seconds
-
toMilliseconds
Converts the given duration into milliseconds.- Parameters:
duration
- the duration- Returns:
- the duration in milliseconds
-
toNanoseconds
Converts the given duration into nanoseconds.- Parameters:
duration
- the duration- Returns:
- the duration in nanoseconds
-
format
Produces a ISO 8601 duration format in the formhh:mm:ss
.- Parameters:
duration
- the duration- Returns:
- the formatted string
-
formatHighResolution
Produces a higher-resolution format string in the formss.mmmm "s"
.- Parameters:
duration
- the duration- Returns:
- the formatted string
-