A duration is an immutable length of time stored as a number of milliseconds.
Various factory and conversion methods are available for convenience.
These static factory methods allow easy construction of value objects using
either long values like seconds(2034) or hours(3):
- Duration.milliseconds(long)
- Duration.seconds(int)
- Duration.minutes(int)
- Duration.hours(int)
- Duration.days(int)
or double precision floating point values like days(3.2):
- Duration.milliseconds(double)
- Duration.seconds(double)
- Duration.minutes(double)
- Duration.hours(double)
- Duration.days(double)
In the case of milliseconds(double), the value will be rounded off to the
nearest integral millisecond using Math.round().
The precise number of milliseconds represented by a Duration object can be
retrieved by calling the milliseconds() method. |