INTERVAL YEAR TO MONTH
data type.
YearToMonth is a Number whose Number#intValue()
represents the number of months of the interval.
Note: only a few databases actually support this data type on its own. You
can still use it for date time arithmetic in other databases, though, through
Field#add(Field) and Field#sub(Field) Databases that have
been observed to natively support INTERVAL data types are:
These dialects have been observed to partially support INTERVAL
data types in date time arithmetic functions, such as
TIMESTAMPADD, and TIMESTAMPDIFF:
Interval
| Modifier and Type | Field and Description |
|---|---|
| private final int | |
| private final boolean | |
| private static final Pattern | |
| private static final Pattern | |
| private final int |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public final YearToMonth | abs()
Implements org. |
| public final int | compareTo(YearToMonth
the object to be compared. that)Implements java. |
| public final double | doubleValue()
Implements abstract java. Implements org. double.
|
| public final boolean | equals(Object
the reference object with which to compare. obj)Overrides java. |
| public final float | floatValue()
Implements abstract java. Implements org. float.
|
| public final int | |
| public final int | |
| public final int | |
| public final int | |
| public final int | intValue()
Implements abstract java. Implements org. int.
|
| public final long | longValue()
Implements abstract java. Implements org. long.
|
| public static YearToMonth | |
| public final YearToMonth | |
| public final Duration | toDuration()
Implements org. |
| public final String | |
| public static YearToMonth | |
| public static YearToMonth | |
| public static YearToMonth | Returns: The parsedYEAR TO MONTH object, or
null if the string could not be parsed.A string representation of the form
string)[+|-][years]-[months]Parse a standard SQL string representation of a
|
| months | back to summary |
|---|---|
| private final int months | |
| negative | back to summary |
|---|---|
| private final boolean negative | |
| PATTERN_ISO | back to summary |
|---|---|
| private static final Pattern PATTERN_ISO | |
| PATTERN_SQL | back to summary |
|---|---|
| private static final Pattern PATTERN_SQL | |
| years | back to summary |
|---|---|
| private final int years | |
| YearToMonth | back to summary |
|---|---|
| public YearToMonth() Create a new year-month interval. | |
| YearToMonth | back to summary |
|---|---|
| public YearToMonth(int years) Create a new year-month interval. | |
| YearToMonth | back to summary |
|---|---|
| public YearToMonth(int years, int months) Create a new year-month interval. | |
| YearToMonth | back to summary |
|---|---|
| pack-priv YearToMonth(int years, int months, boolean negative) | |
| abs | back to summary |
|---|---|
| public final YearToMonth abs() Implements org. Doc from org. Get the absolute value of the interval (set its sign to positive)
| |
| compareTo | back to summary |
|---|---|
| public final int compareTo(YearToMonth that) Implements java. Doc from java. Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. The implementor must ensure The implementor must also ensure that the relation is transitive:
Finally, the implementor must ensure that
| |
| doubleValue | back to summary |
|---|---|
| public final double doubleValue() Implements abstract java. Implements org. Doc from java. Returns the value of the specified number as a
| |
| equals | back to summary |
|---|---|
| public final boolean equals(Object obj) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| floatValue | back to summary |
|---|---|
| public final float floatValue() Implements abstract java. Implements org. Doc from java. Returns the value of the specified number as a
| |
| getMonths | back to summary |
|---|---|
| public final int getMonths() | |
| getSign | back to summary |
|---|---|
| public final int getSign() Implements org. Doc from org. The sign of the interval
| |
| getYears | back to summary |
|---|---|
| public final int getYears() | |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Overrides java. Doc from java. Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| intValue | back to summary |
|---|---|
| public final int intValue() Implements abstract java. Implements org. Doc from java. Returns the value of the specified number as an
| |
| longValue | back to summary |
|---|---|
| public final long longValue() Implements abstract java. Implements org. Doc from java. Returns the value of the specified number as a
| |
| month | back to summary |
|---|---|
| public static YearToMonth month(String string) Parse a standard SQL string representation of a
| |
| neg | back to summary |
|---|---|
| public final YearToMonth neg() Implements org. Doc from org. Negate the interval (change its sign)
| |
| toDuration | back to summary |
|---|---|
| public final Duration toDuration() Implements org. Doc from org. Get a duration representation of this interval.
There is an obvious
This corresponds to PostgreSQL's
| |
| toString | back to summary |
|---|---|
| public final String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
| valueOf | back to summary |
|---|---|
| public static YearToMonth valueOf(String string) Parse a string representation of a
| |
| year | back to summary |
|---|---|
| public static YearToMonth year(String string) Parse a standard SQL string representation of a
| |
| yearToMonth | back to summary |
|---|---|
| public static YearToMonth yearToMonth(String string) Parse a standard SQL string representation of a
| |