Obtains a Duration of zero.
Obtains a Duration representing a number of days.
Tries to obtain a Duration from a temporal amount which has an exact duration.
Obtains a Duration representing a number of hours.
Obtains a Duration representing a number of milliseconds.
Obtains a Duration representing a number of minutes.
Obtains a Duration representing a number of nanoseconds.
Tries to obtain a Duration from text based on the ISO-8601 Duration format - PnDTnHnMn.
Tries to obtain a Duration from text based on the ISO-8601 Duration format - PnDTnHnMn.nS - with days considered to be exactly 24 hours.
The text starts with an optional sign, denoted by the ASCII negative or positive symbol. If negative, the whole period is negated.
The ASCII letter "P" is next in upper or lower case.
There are then four sections, each consisting of a number and a suffix. The sections have suffixes in ASCII of "D", "H", "M" and "S" for days, hours, minutes and seconds, accepted in upper or lower case.
The suffixes must occur in order. The ASCII letter "T" must occur before the first occurrence, if any, of an hour, minute or second section. At least one of the four sections must be present, and if "T" is present there must be at least one section after the "T". The number part of each section must consist of one or more ASCII digits. The number may be prefixed by the ASCII negative or positive symbol. The number of days, hours and minutes must parse to an long. The number of seconds must parse to a long with optional fraction. The decimal point may be either a dot or a comma. The fractional part may have from zero to 9 digits.
The leading plus/minus sign, and negative values for other units are not part of the ISO-8601 standard.
import codes.reactive.scalatime._ // Parses as 20.345 seconds val dur1 = Duration.parse("PT20.345S") // Parses as 2 days, 3 hours, 4 minutes val dur2 = Duration.parse("P2DT3H4M") // Parses as minus 6 hours, 3 minutes val dur3 = Duration.parse("P-6H3M")
Obtains a Duration representing a number of seconds adjusted by a number of nano-seconds.
Obtains a Duration representing a number of seconds.
Factory object for obtaining instances of Duration.
Duration is a time-based amount of time, such as '34.5 seconds'.
Direct use of this object is not the only mechanism to obtain Duration instances. See also the syntax syntax for alternatives.