The IntervalYM methods
The following methods allow you to manipulate year-month
intervals. (You can also use the Interval methods, described
previously.) Some of the tasks you can perform with IntervalYM methods
include the following:
- Comparing two intervals:
boolean equals(Object other) boolean greaterThan(IntervalYM other) boolean lessThan(IntervalYM other)
- Setting a value for an interval from:
- A string:
void fromString(String other) void set(String string)
- Year and month values (large month values are converted to years):
void set(int years, int months)
- Two time stamps:
void set(Timestamp t1, Timestamp t2)
- A string:
- Setting the qualifier for an interval:
- From the length, start code, and end code:
void setQualifier(int length, byte startcode, byte endcode)
- Using an existing qualifier:
void setQualifier(short qualifier)
- From the length, start code, and end code:
- Obtaining the number of months in the interval:
long getMonths()
- Creating a string representation of the interval in the format
yyyy-mm
:String toString()
The fields present depend on the qualifier. Blanks replace leading zeros.