public final class YearToMonth extends Number implements Interval, Comparable<YearToMonth>
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,
Serialized Form| Constructor and Description |
|---|
YearToMonth(int years)
Create a new year-month interval.
|
YearToMonth(int years,
int months)
Create a new year-month interval.
|
| Modifier and Type | Method and Description |
|---|---|
YearToMonth |
abs()
Get the absolute value of the interval (set its sign to positive)
|
int |
compareTo(YearToMonth that) |
double |
doubleValue() |
boolean |
equals(Object obj) |
float |
floatValue() |
int |
getMonths() |
int |
getSign()
The sign of the interval
|
int |
getYears() |
int |
hashCode() |
int |
intValue() |
long |
longValue() |
YearToMonth |
neg()
Negate the interval (change its sign)
|
String |
toString() |
static YearToMonth |
valueOf(String string)
Parse a string representation of a
INTERVAL YEAR TO MONTH |
byteValue, shortValueclone, finalize, getClass, notify, notifyAll, wait, wait, waitbyteValue, shortValuepublic YearToMonth(int years)
public YearToMonth(int years,
int months)
public static YearToMonth valueOf(String string)
INTERVAL YEAR TO MONTHstring - A string representation of the form
[+|-][years]-[months]YEAR TO MONTH object, or
null if the string could not be parsed.public final YearToMonth neg()
Intervalpublic final YearToMonth abs()
Intervalpublic final int getYears()
public final int getMonths()
public final int getSign()
Intervalpublic final int intValue()
intValue in interface IntervalintValue in class NumberNumber.intValue()public final long longValue()
longValue in interface IntervallongValue in class NumberNumber.longValue()public final float floatValue()
floatValue in interface IntervalfloatValue in class NumberNumber.floatValue()public final double doubleValue()
doubleValue in interface IntervaldoubleValue in class NumberNumber.doubleValue()public final int compareTo(YearToMonth that)
compareTo in interface Comparable<YearToMonth>Copyright © 2019. All rights reserved.