parseUnitBasedDuration

fun parseUnitBasedDuration(durationText: CharSequence): Duration(source)

Parses formatted durations based on units.

The behaviour matches the Golang duration parser, however, infinite durations are not supported.

The duration format is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".

Note, the value "0" is specially supported as Duration.ZERO.

Return

the Duration value represented by the string, if possible.

Parameters

durationText

the formatted unit-based duration string.