GDuration Class
- public final class GDuration
extends Object
implements GDurationSpecification
, Serializable
Represents an XML Schema-compatible duration.
A duration is made up of a number of years, months, days, hours,
minutes, seconds, and fractions of seconds. See the
XML Schema specification
section on xs:duration
for details on the rules for
comparing durations and
adding durations to dates.
-
Hierarchy
-
Object
GDuration
-
All Implemented Interfaces
-
GDurationSpecification
, Serializable
-
GDuration()
- Constructs an empty GDuration representing zero seconds.
|
-
GDuration(
GDurationSpecification gDuration)
- Constructs a GDuration from another GDurationSpecification.
|
-
GDuration(int sign, int year, int month, int day, int hour, int minute, int second,
BigDecimal fraction)
- Constructs a GDuration with the specified sign,
year, month, day, hours, minutes, seconds, and optional
fractional seconds.
|
-
GDuration(
CharSequence str)
- Constructs a GDuration from a lexical
representation.
|
public GDuration |
-
add (GDurationSpecification duration)
- Returns a new GDuration which is the sum of this one and the
supplied duration.
|
public Object |
-
clone ()
- Builds another GDate with the same value
as this one.
|
public final int |
-
compareToGDuration (GDurationSpecification duration)
- Comparison to another GDuration.
|
public boolean |
-
equals (Object obj)
- Two GDurations are equal if all their fields are equal.
|
public final int |
-
getDay ()
- Gets the day-of-month component.
|
public BigDecimal |
-
getFraction ()
- Gets the fraction-of-second.
|
public final int |
-
getHour ()
- Gets the hour-of-day component.
|
public final int |
-
getMinute ()
- Gets the minute-of-hour component.
|
public final int |
-
getMonth ()
- Gets the month-of-year component.
|
public final int |
-
getSecond ()
- Gets the second-of-minute component.
|
public final int |
-
getSign ()
- Returns the sign of the duration: +1 is forwards
and -1 is backwards in time.
|
public final int |
-
getYear ()
- Gets the year component.
|
public int |
-
hashCode ()
|
public final boolean |
-
isImmutable ()
- All GDuration instances return true.
|
public boolean |
-
isValid ()
- Returns true if all of the individual components
of the duration are nonnegative.
|
public GDuration |
-
subtract (GDurationSpecification duration)
- Returns a new GDuration which is the result of subtracting
the supplied duration from this one.
|
public String |
-
toString ()
- The natural string representation of the duration.
|
Methods from interface com.bea.xml.GDurationSpecification |
compareToGDuration , getDay , getFraction , getHour , getMinute , getMonth , getSecond , getSign , getYear , isImmutable , isValid
|
GDuration
public GDuration()
- Constructs an empty GDuration representing zero seconds.
GDuration
public GDuration(GDurationSpecification
gDuration)
- Constructs a GDuration from another GDurationSpecification.
GDuration
public GDuration(int sign,
int year,
int month,
int day,
int hour,
int minute,
int second,
BigDecimal
fraction)
- Constructs a GDuration with the specified sign,
year, month, day, hours, minutes, seconds, and optional
fractional seconds.
GDuration
public GDuration(CharSequence
str)
- Constructs a GDuration from a lexical
representation. The lexical space contains the
union of the lexical spaces of all the schema
date/time types (except for duration).
add(GDurationSpecification) Method
public GDuration
add(GDurationSpecification
duration)
Returns a new GDuration which is the sum of this one and the
supplied duration. Does a fieldwise addition, with no normalization.
clone() Method
public Object
clone()
Builds another GDate with the same value
as this one.
-
Overrides
-
Object.clone()
compareToGDuration(GDurationSpecification) Method
public final int compareToGDuration(GDurationSpecification
duration)
Comparison to another GDuration.
- Returns -1 if this < date. (less-than)
- Returns 0 if this == date. (equal)
- Returns 1 if this > date. (greater-than)
- Returns 2 if this <> date. (incomparable)
Two instances are incomparable if they have different amounts
of information.
equals(Object) Method
public boolean equals(Object
obj)
Two GDurations are equal if all their fields are equal.
The equals function does not apply normalizatin.
-
Overrides
-
Object.equals(Object)
getDay() Method
public final int getDay()
Gets the day-of-month component.
getFraction() Method
public BigDecimal
getFraction()
Gets the fraction-of-second. Range from 0 (inclusive) to 1 (exclusive).
getHour() Method
public final int getHour()
Gets the hour-of-day component.
getMinute() Method
public final int getMinute()
Gets the minute-of-hour component.
getMonth() Method
public final int getMonth()
Gets the month-of-year component.
getSecond() Method
public final int getSecond()
Gets the second-of-minute component.
getSign() Method
public final int getSign()
Returns the sign of the duration: +1 is forwards
and -1 is backwards in time.
getYear() Method
public final int getYear()
Gets the year component.
hashCode() Method
public int hashCode()
-
Overrides
-
Object.hashCode()
isImmutable() Method
public final boolean isImmutable()
All GDuration instances return true.
isValid() Method
public boolean isValid()
Returns true if all of the individual components
of the duration are nonnegative.
subtract(GDurationSpecification) Method
public GDuration
subtract(GDurationSpecification
duration)
Returns a new GDuration which is the result of subtracting
the supplied duration from this one. Does a fieldwise
subtraction, with no normalization.
toString() Method
public String
toString()
The natural string representation of the duration.
Any components that are zero are omitted. Note that if the duration
is invalid, i.e., it has negative components, those negative
components are serialized out here. To check for validity, use
the isValid() method; and to normalize most durations to a valid
form use the normalize() method.
-
Overrides
-
Object.toString()