public final class YearToMonth extends java.lang.Number implements Interval, java.lang.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(java.lang.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)
|
java.lang.String |
toString() |
static YearToMonth |
valueOf(java.lang.String string)
Parse a string representation of a
INTERVAL YEAR TO MONTH |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
byteValue, shortValue
public YearToMonth(int years)
public YearToMonth(int years, int months)
public static YearToMonth valueOf(java.lang.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()
public final long longValue()
public final float floatValue()
floatValue
in interface Interval
floatValue
in class java.lang.Number
Number.floatValue()
public final double doubleValue()
doubleValue
in interface Interval
doubleValue
in class java.lang.Number
Number.doubleValue()
public final int compareTo(YearToMonth that)
compareTo
in interface java.lang.Comparable<YearToMonth>
public final int hashCode()
hashCode
in class java.lang.Object
public final boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public final java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2015. All Rights Reserved.