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 StringProduces a ISO 8601 duration format in the formhh:mm:ss.static final StringformatHighResolution(Duration duration) Produces a higher-resolution format string in the formss.mmmm "s".static final booleanisGreaterThanOrEqual(Duration lhs, Duration rhs) Returnstrueif the left-hand side is greater than or equal to the right-hand side duration.static final longtoMilliseconds(Duration duration) Converts the given duration into milliseconds.static final longtoNanoseconds(Duration duration) Converts the given duration into nanoseconds.static final doubletoPercentage(Duration elapsed, Duration total) Returns the percentage as a value between0.0and100.0showing the percent complete.static final doubleConverts the given duration into fractional seconds.
-
Method Details
-
isGreaterThanOrEqual
Returnstrueif 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:
trueif greater than or equal;falseotherwise
-
toPercentage
Returns the percentage as a value between0.0and100.0showing 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
-