Constructor and Description |
---|
Duration() |
Modifier and Type | Method and Description |
---|---|
abstract Duration |
add(Duration rhs)
Returns the result of adding the specified duration to this duration.
|
abstract void |
addTo(Calendar calendar)
Adds this duration to the specified calendar.
|
void |
addTo(Date date)
Adds this duration to the specified date.
|
abstract int |
compare(Duration duration)
Partial order relation comparison with this duration, in accordance
with XML Schema 1.0 Part 2, Section 3.2.7.6.2.
|
boolean |
equals(Object duration)
Determine whether this Object is semantically equal
to another Object.
|
int |
getDays()
Returns the days in this duration as an int, or 0 if not present.
|
abstract Number |
getField(DatatypeConstants.Field field)
Returns the value of the specified field, or
null if the
field is undefined. |
int |
getHours()
Returns the hours in this duration as an int, or 0 if not present.
|
int |
getMinutes()
Returns the minutes in this duration as an int, or 0 if not present.
|
int |
getMonths()
Returns the months in this duration as an int, or 0 if not present.
|
int |
getSeconds()
Returns the seconds in this duration as an int, or 0 if not present.
|
abstract int |
getSign()
Returns the sign of this value.
|
long |
getTimeInMillis(Calendar startInstant)
Returns the duration length in milliseconds.
|
long |
getTimeInMillis(Date startInstant)
Returns the duration length in milliseconds.
|
QName |
getXMLSchemaType()
Returns the name of the XML Schema data type this value maps to.
|
int |
getYears()
Returns the years in this duration as an int, or 0 if not present.
|
abstract int |
hashCode()
Get a value that represents this Object, as uniquely as
possible within the confines of an int.
|
boolean |
isLongerThan(Duration duration) |
abstract boolean |
isSet(DatatypeConstants.Field field)
Indicates whether the specified field is set.
|
boolean |
isShorterThan(Duration duration) |
abstract Duration |
multiply(BigDecimal factor)
Returns the result of multiplying this duration by the given factor.
|
Duration |
multiply(int factor)
Returns the result of multiplying this duration by the given factor.
|
abstract Duration |
negate()
Returns the unary negative of this duration.
|
abstract Duration |
normalizeWith(Calendar startTimeInstant)
Converts the years and months fields into the days field using a
specific time instant as the reference point.
|
Duration |
subtract(Duration rhs)
Returns the result of subtracting the given duration from this
duration.
|
String |
toString()
Returns the lexical representation of this duration.
|
public Duration()
public QName getXMLSchemaType()
public abstract int getSign()
public int getYears()
public int getMonths()
public int getDays()
public int getHours()
public int getMinutes()
public int getSeconds()
public long getTimeInMillis(Calendar startInstant)
startInstant
parameter is used to specify the duration
offset.public long getTimeInMillis(Date startInstant)
startInstant
parameter is used to specify the duration
offset.public abstract Number getField(DatatypeConstants.Field field)
null
if the
field is undefined.public abstract boolean isSet(DatatypeConstants.Field field)
public abstract Duration add(Duration rhs)
public Duration subtract(Duration rhs)
public Duration multiply(int factor)
public abstract Duration multiply(BigDecimal factor)
public abstract Duration normalizeWith(Calendar startTimeInstant)
public abstract int compare(Duration duration)
public boolean isLongerThan(Duration duration)
public boolean isShorterThan(Duration duration)
public boolean equals(Object duration)
Object
There are some fairly strict requirements on this
method which subclasses must follow:
a.equals(b)
and
b.equals(c)
, then a.equals(c)
must be true as well.a.equals(b)
and
b.equals(a)
must have the same value.a.equals(a)
must
always be true.a.equals(null)
must be false.a.equals(b)
must imply
a.hashCode() == b.hashCode()
.
The reverse is not true; two objects that are not
equal may have the same hashcode, but that has
the potential to harm hashing performance.This is typically overridden to throw a ClassCastException
if the argument is not comparable to the class performing
the comparison, but that is not a requirement. It is legal
for a.equals(b)
to be true even though
a.getClass() != b.getClass()
. Also, it
is typical to never cause a NullPointerException
.
In general, the Collections API (java.util
) use the
equals
method rather than the ==
operator to compare objects. However, IdentityHashMap
is an exception to this rule, for its own good reasons.
The default implementation returns this == o
.
equals
in class Object
duration
- the Object to compare toObject.hashCode()
public abstract int hashCode()
Object
There are some requirements on this method which
subclasses must follow:
a.equals(b)
is true, then
a.hashCode() == b.hashCode()
must be as well.
However, the reverse is not necessarily true, and two
objects may have the same hashcode without being equal.Notice that since hashCode
is used in
Hashtable
and other hashing classes,
a poor implementation will degrade the performance of hashing
(so don't blindly implement it as returning a constant!). Also,
if calculating the hash is time-consuming, a class may consider
caching the results.
The default implementation returns
System.identityHashCode(this)
hashCode
in class Object
Object.equals(Object)
,
System.identityHashCode(Object)
public String toString()
toString
in class Object
Object.getClass()
,
Object.hashCode()
,
Class.getName()
,
Integer.toHexString(int)