GDurationBuilder Class
com.bea.xml
GDurationBuilder Class
- public class GDurationBuilder
extends Object
implements GDurationSpecification
, Serializable
Used to build GDuration
.
-
Hierarchy
-
Object
GDurationBuilder
-
All Implemented Interfaces
-
GDurationSpecification
, Serializable
-
GDurationBuilder()
- Constructs an empty GDurationBuilder representing zero seconds.
|
-
GDurationBuilder(
GDurationSpecification gDuration)
- Constructs a GDurationBuilder from another GDurationBuilderSpecification.
|
-
GDurationBuilder(int sign, int year, int month, int day, int hour, int minute, int second,
BigDecimal fraction)
- Constructs a GDurationBuilder with the specified sign,
year, month, day, hours, minutes, seconds, and optional
fractional seconds.
|
-
GDurationBuilder(
String s)
- Constructs a GDuration from a lexical
representation.
|
public void |
-
addGDuration (GDurationSpecification duration)
- Adds to this duration.
|
public Object |
-
clone ()
- Builds another GDurationBuilder with the same value
as this one.
|
public final int |
-
compareToGDuration (GDurationSpecification duration)
- Comparison to another GDuration.
|
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 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 void |
-
normalize ()
- Normalize a duration value.
|
public void |
-
setDay (int day)
- Sets the day component.
|
public void |
-
setFraction (BigDecimal fraction)
- Sets the fraction-of-second component.
|
public void |
-
setHour (int hour)
- Sets the hour component.
|
public void |
-
setMinute (int minute)
- Sets the minute component.
|
public void |
-
setMonth (int month)
- Sets the month component.
|
public void |
-
setSecond (int second)
- Sets the second component.
|
public final void |
-
setSign (int sign)
- Sets the sign.
|
public void |
-
setYear (int year)
- Sets the year component.
|
public void |
-
subtractGDuration (GDurationSpecification duration)
- Subtracts from this duration.
|
public GDuration |
-
toGDuration ()
- Builds a GDuration from this GDurationBuilder.
|
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
|
GDurationBuilder
public GDurationBuilder()
- Constructs an empty GDurationBuilder representing zero seconds.
GDurationBuilder
public GDurationBuilder(GDurationSpecification
gDuration)
- Constructs a GDurationBuilder from another GDurationBuilderSpecification.
GDurationBuilder
public GDurationBuilder(int sign,
int year,
int month,
int day,
int hour,
int minute,
int second,
BigDecimal
fraction)
- Constructs a GDurationBuilder with the specified sign,
year, month, day, hours, minutes, seconds, and optional
fractional seconds.
GDurationBuilder
public GDurationBuilder(String
s)
- Constructs a GDuration from a lexical
representation.
addGDuration(GDurationSpecification) Method
public void addGDuration(GDurationSpecification
duration)
Adds to this duration. Does a fieldwise add, with no
normalization.
clone() Method
public Object
clone()
Builds another GDurationBuilder 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.
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.
This value does not necessarily reflect the
true direction of the duration if the duration
is not normalized or not normalizable.
getYear() Method
public final int getYear()
Gets the year component.
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.
normalize() Method
public void normalize()
Normalize a duration value. This ensures that months,
hours, minutes, seconds, and fractions are positive and
within the ranges 0..11, 0..23, 0..59, etc. Negative
durations are indicated by a negative sign rather
than negative components.
Most duration specifications can be normalized to
valid durations with all positive components, but
not all of them can.
The only situations which cannot be normalized are
where the year/month and the day/hour/minute/second
offsets are of opposite sign. Days cannot be carried
into months since the length of a Gregorian month is
variable depending on when the duration is applied.
In these cases, this method normalizes the components
so that "day" is the only negative component.
setDay(int) Method
public void setDay(int day)
Sets the day component.
setFraction(BigDecimal) Method
public void setFraction(BigDecimal
fraction)
Sets the fraction-of-second component.
setHour(int) Method
public void setHour(int hour)
Sets the hour component.
setMinute(int) Method
public void setMinute(int minute)
Sets the minute component.
setMonth(int) Method
public void setMonth(int month)
Sets the month component.
setSecond(int) Method
public void setSecond(int second)
Sets the second component.
setSign(int) Method
public final void setSign(int sign)
Sets the sign.
setYear(int) Method
public void setYear(int year)
Sets the year component.
subtractGDuration(GDurationSpecification) Method
public void subtractGDuration(GDurationSpecification
duration)
Subtracts from this duration. Does a fieldwise subtraction,
with no normalization.
toGDuration() Method
public GDuration
toGDuration()
Builds a GDuration from this GDurationBuilder.
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()