class Duration
Represents a duration. A duration stores separately months, days, and seconds due to the fact that the number of days in a month varies, and a day can have 23 or 25 hours if a daylight saving is involved.
Members
Number
days
Gets the number of days.
Number
months
Gets the number of months.
Long
nanoseconds
Gets the number of nanoseconds represented as a int64
.
Constructor
Methods
Duration.fromBuffer
(Buffer
buffer)
Creates a new Duration
instance from the binary representation of the value.
- Static
- This function is static
Duration.fromString
(String
input)
Creates a new Duration
instance from the string representation of the value.
Accepted formats:
- multiple digits followed by a time unit like: 12h30m where the time unit can be:
- {@code y}: years
- {@code m}: months
- {@code w}: weeks
- {@code d}: days
- {@code h}: hours
- {@code m}: minutes
- {@code s}: seconds
- {@code ms}: milliseconds
- {@code us} or {@code µs}: microseconds
- {@code ns}: nanoseconds
- ISO 8601 format:
P[n]Y[n]M[n]DT[n]H[n]M[n]S or P[n]W
- ISO 8601 alternative format:
P[YYYY]-[MM]-[DD]T[hh]:[mm]:[ss]
- Static
- This function is static
toBuffer
()Serializes the duration and returns the representation of the value in bytes.
toString
()Returns the string representation of the value.