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 FormConstructor 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, shortValue
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
byteValue, shortValue
public YearToMonth(int years)
public YearToMonth(int years, int months)
public static YearToMonth valueOf(String string)
INTERVAL YEAR TO MONTH
string
- 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()
Interval
public final YearToMonth abs()
Interval
public final int getYears()
public final int getMonths()
public final int getSign()
Interval
public final int intValue()
intValue
in interface Interval
intValue
in class Number
Number.intValue()
public final long longValue()
longValue
in interface Interval
longValue
in class Number
Number.longValue()
public final float floatValue()
floatValue
in interface Interval
floatValue
in class Number
Number.floatValue()
public final double doubleValue()
doubleValue
in interface Interval
doubleValue
in class Number
Number.doubleValue()
public final int compareTo(YearToMonth that)
compareTo
in interface Comparable<YearToMonth>
Copyright © 2014. All Rights Reserved.