Package org.nuxeo.common.utils
Class DurationUtils
java.lang.Object
org.nuxeo.common.utils.DurationUtils
- Since:
- 11.1
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Duration
Obtains aDuration
from a text string such asPnDTnHnMn.nS
or_d_h_m_s_ms
.static Duration
parsePositive
(String value, Duration defaultDuration) Obtains aDuration
from a text string according toparse(String)
, but in case of invalid, zero or negative duration returns a default.
-
Field Details
-
DURATION_SIMPLE_FORMAT
-
-
Method Details
-
parse
Obtains aDuration
from a text string such asPnDTnHnMn.nS
or_d_h_m_s_ms
.See
Duration.parse(CharSequence)
forPnDTnHnMn.nS
format.For
_d_h_m_s_ms
, there are five sections, each consisting of a number and a suffix. The suffixes are "d", "h", "m", "s" and "ms" for days, hours, minutes, seconds and milliseconds. The suffixes must occur in order and at least one of them must be present.- Throws:
DateTimeParseException
- if the text cannot be parsed to a duration- See Also:
-
parsePositive
Obtains aDuration
from a text string according toparse(String)
, but in case of invalid, zero or negative duration returns a default.- Parameters:
value
- the value to parsedefaultDuration
- the default duration to return for invalid, zero or negative duration- Returns:
- the parsed duration (positive), or the default
- Since:
- 11.1
-