The Time Framework for Java models time as a series of instantaneous events, known as {@link Instant instants}, along a single time-line. This class represents the duration between two of those instants.
A physical instant is an instantaneous event. However, for practicality the API and this class uses a precision of nanoseconds.
A physical duration could be of infinite length. However, for practicality the API and this class limits the length to the number of seconds that can be held in a {@code long}.
In order to represent the data a 96 bit number is required. To achieve this the data is stored as seconds, measured using a {@code long}, and nanoseconds, measured using an {@code int}. The nanosecond part will always be between 0 and 999,999,999 representing the nanosecond part of the second. For example, the negative duration of {@code PT-0.1S} is represented as-1 second and 900,000,000 nanoseconds.
In this API, the unit of "seconds" only has a precise meaning when applied to an instant. This is because it is the instant that defines the time scale used, not the duration. For example, the simplified UTC time scale used by {@code Instant} ignores leap seconds,which alters the effective length of a second. By comparison, the TAI time scale follows the international scientific definition of a second exactly. For most applications, this subtlety will be irrelevant.
Duration is immutable and thread-safe. @author Michael Nascimento Santos @author Stephen Colebourne
|
|
|
|