Immutable representation of a time span as defined in the W3C XML Schema 1.0 specification.
A Duration object represents a period of Gregorian time, which consists of six fields (years, months, days, hours, minutes, and seconds) plus a sign (+/-) field.
The first five fields have non-negative (>=0) integers or null (which represents that the field is not set), and the seconds field has a non-negative decimal or null. A negative sign indicates a negative duration.
This class provides a number of methods that make it easy to use for the duration datatype of XML Schema 1.0 with the errata.
Duration objects only have partial order, where two values A and B maybe either:
For example, 30 days cannot be meaningfully compared to one month. The {@link #compare(Duration duration)} method implements thisrelationship.
See the {@link #isLongerThan(Duration)} method for details aboutthe order relationship among Duration
objects.
This class provides a set of basic arithmetic operations, such as addition, subtraction and multiplication. Because durations don't have total order, an operation could fail for some combinations of operations. For example, you cannot subtract 15 days from 1 month. See the javadoc of those methods for detailed conditions where this could happen.
Also, division of a duration by a number is not provided because the Duration
class can only deal with finite precision decimal numbers. For example, one cannot represent 1 sec divided by 3.
However, you could substitute a division by 3 with multiplying by numbers such as 0.3 or 0.333.
Because some operations of Duration
rely on {@link Calendar}even though {@link Duration} can hold very large or very small values,some of the methods may not work correctly on such Duration
s. The impacted methods document their dependency on {@link Calendar}.
@author Joseph Fialli
@author Kohsuke Kawaguchi
@author Jeff Suttor
@version $Revision: 292853 $, $Date: 2005-09-30 16:42:07 -0400 (Fri, 30 Sep 2005) $
@see XMLGregorianCalendar#add(Duration)
@since 1.5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|