|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.xmlbeans.GDurationBuilder
public class GDurationBuilder
Used to build GDurations
.
Constructor Summary | |
---|---|
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,
java.math.BigDecimal fraction)
Constructs a GDurationBuilder with the specified sign, year, month, day, hours, minutes, seconds, and optional fractional seconds. |
|
GDurationBuilder(java.lang.String s)
Constructs a GDuration from a lexical representation. |
Method Summary | |
---|---|
void |
addGDuration(GDurationSpecification duration)
Adds to this duration. |
java.lang.Object |
clone()
Builds another GDurationBuilder with the same value as this one. |
int |
compareToGDuration(GDurationSpecification duration)
Comparison to another GDuration. |
int |
getDay()
Gets the day-of-month component. |
java.math.BigDecimal |
getFraction()
Gets the fraction-of-second. |
int |
getHour()
Gets the hour-of-day component. |
int |
getMinute()
Gets the minute-of-hour component. |
int |
getMonth()
Gets the month-of-year component. |
int |
getSecond()
Gets the second-of-minute component. |
int |
getSign()
Returns the sign of the duration: +1 is forwards and -1 is backwards in time. |
int |
getYear()
Gets the year component. |
boolean |
isImmutable()
All GDuration instances return true. |
boolean |
isValid()
Returns true if all of the individual components of the duration are nonnegative. |
void |
normalize()
Normalize a duration value. |
void |
setDay(int day)
Sets the day component. |
void |
setFraction(java.math.BigDecimal fraction)
Sets the fraction-of-second component. |
void |
setHour(int hour)
Sets the hour component. |
void |
setMinute(int minute)
Sets the minute component. |
void |
setMonth(int month)
Sets the month component. |
void |
setSecond(int second)
Sets the second component. |
void |
setSign(int sign)
Sets the sign. |
void |
setYear(int year)
Sets the year component. |
static java.lang.String |
stripTrailingZeros(java.lang.String s)
|
void |
subtractGDuration(GDurationSpecification duration)
Subtracts from this duration. |
GDuration |
toGDuration()
Builds a GDuration from this GDurationBuilder. |
static java.lang.String |
toPlainString(java.math.BigDecimal bd)
|
java.lang.String |
toString()
The natural string representation of the duration. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public GDurationBuilder()
public GDurationBuilder(java.lang.String s)
public GDurationBuilder(int sign, int year, int month, int day, int hour, int minute, int second, java.math.BigDecimal fraction)
sign
- +1 for a positive duration, -1 for a negative duration
java.lang.IllegalArgumentException
- if the sign is not 1 or -1public GDurationBuilder(GDurationSpecification gDuration)
Method Detail |
---|
public java.lang.Object clone()
clone
in class java.lang.Object
public GDuration toGDuration()
public void addGDuration(GDurationSpecification duration)
public void subtractGDuration(GDurationSpecification duration)
public final void setSign(int sign)
public void setYear(int year)
public void setMonth(int month)
public void setDay(int day)
public void setHour(int hour)
public void setMinute(int minute)
public void setSecond(int second)
public void setFraction(java.math.BigDecimal fraction)
public final boolean isImmutable()
isImmutable
in interface GDurationSpecification
public final int getSign()
getSign
in interface GDurationSpecification
public final int getYear()
getYear
in interface GDurationSpecification
public final int getMonth()
getMonth
in interface GDurationSpecification
public final int getDay()
getDay
in interface GDurationSpecification
public final int getHour()
getHour
in interface GDurationSpecification
public final int getMinute()
getMinute
in interface GDurationSpecification
public final int getSecond()
getSecond
in interface GDurationSpecification
public java.math.BigDecimal getFraction()
getFraction
in interface GDurationSpecification
public boolean isValid()
isValid
in interface GDurationSpecification
public void normalize()
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.
public final int compareToGDuration(GDurationSpecification duration)
compareToGDuration
in interface GDurationSpecification
public java.lang.String toString()
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.
toString
in class java.lang.Object
public static java.lang.String toPlainString(java.math.BigDecimal bd)
public static java.lang.String stripTrailingZeros(java.lang.String s)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |