Readonly
nanosthe number of nanoseconds
Readonly
secondsthe number of seconds
Static
Readonly
FOREVERA constant for a duration of forever.
Static
Readonly
ZEROA constant for a duration of zero.
Compares this duration to the specified duration.
the duration being compared to this duration
a negative value if this duration is less than the specified duration, a positive value if this duration is greater than the specified duration, or zero if the two durations are equal.
Creates a new Duration instance by subtracting the specified number of days from this duration.
the number of days to subtract
a new Duration instance with the difference of this duration and the specified number of days.
Creates a new Duration instance by subtracting the specified number of hours from this duration.
the number of hours to subtract
a new Duration instance with the difference of this duration and the specified number of hours.
Creates a new Duration instance by subtracting the specified number of milliseconds from this duration.
the number of milliseconds to subtract
a new Duration instance with the difference of this duration and the specified number of milliseconds.
Creates a new Duration instance by subtracting the specified number of minutes from this duration.
the number of minutes to subtract
a new Duration instance with the difference of this duration and the specified number of minutes.
Creates a new Duration instance by subtracting the specified number of nanoseconds from this duration.
the number of nanoseconds to subtract
a new Duration instance with the difference of this duration and the specified number of nanoseconds.
Creates a new Duration instance by subtracting the specified number of seconds from this duration.
the number of seconds to subtract
a new Duration instance with the difference of this duration and the specified number of seconds.
Creates a new Duration instance by adding the specified number of milliseconds to this duration.
the number of milliseconds to add
a new Duration instance with the sum of this duration and the specified number of milliseconds.
Creates a new Duration instance by adding the specified number of minutes to this duration.
the number of minutes to add
a new Duration instance with the sum of this duration and the specified number of minutes.
Creates a new Duration instance by adding the specified number of nanoseconds to this duration.
the number of nanoseconds to add
a new Duration instance with the sum of this duration and the specified number of nanoseconds.
Creates a new Duration instance by adding the specified number of seconds to this duration.
the number of seconds to add
a new Duration instance with the sum of this duration and the specified number of seconds.
Creates a new Duration instance with the specified number of nanoseconds. The current number of seconds in this duration is preserved.
the number of nanoseconds for the new duration
a new Duration instance with the specified number of nanoseconds.
Creates a new Duration instance with the specified number of seconds. The current number of nanoseconds in this duration is preserved.
the number of seconds for the new duration
a new Duration instance with the specified number of seconds.
Static
ofStatic
ofStatic
ofStatic
ofStatic
ofStatic
ofStatic
ofCreates a new Duration instance representing the specified number of seconds adjusted by a number of nanoseconds.
the number of seconds
the number of nanoseconds by which to adjust the seconds
a new Duration instance representing the specified number of seconds adjusted by the specified number of nanoseconds.
A time-based amount of time, such as '34.5 seconds'.
This class models a quantity or amount of time in terms of seconds and nanoseconds. It can be accessed using other duration-based units, such as minutes and hours. In addition, the DAYS unit can be used and is treated as exactly equal to 24 hours, thus ignoring daylight savings effects.
A physical duration could be of infinite length. The duration uses nanosecond resolution with a maximum value of the seconds that can be held in a long. This is greater than the current estimated age of the universe.
The range of a duration requires the storage of a number larger than a long. To achieve this, the class stores a long representing seconds and an integer representing nanosecond-of-second, which will always be between 0 and 999,999,999. The model is of a directed duration, meaning that the duration may be negative.
The duration is measured in "seconds", but these are not necessarily identical to the scientific "SI second" definition based on atomic clocks. This difference only impacts durations measured near a leap-second and should not affect most applications.
This is a value-based class; use of identity-sensitive operations on instances of Duration may have unpredictable results and should be avoided. The equals method should be used for comparisons.