parseDuration
parseDuration
parses a string argument as a Duration, which is a unit of time in terms of wall clock time (days, hours, minutes, seconds, and nanoseconds).
Duration strings are formatted according to the ISO-8601 duration format as [-]PnDTnHnMn.nS
, where the coefficients can be positive or negative. Zero coefficients can be omitted. Optionally, the string can begin with a negative sign.
Throws an exception if the string cannot be parsed.
Syntax
parseDuration(s)
Parameters
Parameter | Type | Description |
---|---|---|
s | string | The string to be converted. Time duration strings can be formatted as |
Returns
A Duration.
Examples
one_day = parseDuration("P1D")
one_hour = parseDuration("PT1H")
println one_day
println one_hour
- Log