org.jooq.types
Class YearToMonth

java.lang.Object
  extended by java.lang.Number
      extended by org.jooq.types.YearToMonth
All Implemented Interfaces:
Serializable, Comparable<YearToMonth>, Interval

public final class YearToMonth
extends Number
implements Interval, Comparable<YearToMonth>

An implementation for the SQL standard 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:

Author:
Lukas Eder
See Also:
Interval, Serialized Form

Constructor Summary
YearToMonth(int years)
          Create a new year-month interval.
YearToMonth(int years, int months)
          Create a new year-month interval.
 
Method Summary
 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
 
Methods inherited from class java.lang.Number
byteValue, shortValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jooq.types.Interval
byteValue, shortValue
 

Constructor Detail

YearToMonth

public YearToMonth(int years)
Create a new year-month interval.


YearToMonth

public YearToMonth(int years,
                   int months)
Create a new year-month interval.

Method Detail

valueOf

public static YearToMonth valueOf(String string)
Parse a string representation of a INTERVAL YEAR TO MONTH

Parameters:
string - A string representation of the form [+|-][years]-[months]
Returns:
The parsed YEAR TO MONTH object, or null if the string could not be parsed.

neg

public final YearToMonth neg()
Description copied from interface: Interval
Negate the interval (change its sign)

Specified by:
neg in interface Interval

abs

public final YearToMonth abs()
Description copied from interface: Interval
Get the absolute value of the interval (set its sign to positive)

Specified by:
abs in interface Interval

getYears

public final int getYears()

getMonths

public final int getMonths()

getSign

public final int getSign()
Description copied from interface: Interval
The sign of the interval

Specified by:
getSign in interface Interval
Returns:
1 for positive or zero, -1 for negative

intValue

public final int intValue()
Specified by:
intValue in interface Interval
Specified by:
intValue in class Number
See Also:
Number.intValue()

longValue

public final long longValue()
Specified by:
longValue in interface Interval
Specified by:
longValue in class Number
See Also:
Number.longValue()

floatValue

public final float floatValue()
Specified by:
floatValue in interface Interval
Specified by:
floatValue in class Number
See Also:
Number.floatValue()

doubleValue

public final double doubleValue()
Specified by:
doubleValue in interface Interval
Specified by:
doubleValue in class Number
See Also:
Number.doubleValue()

compareTo

public final int compareTo(YearToMonth that)
Specified by:
compareTo in interface Comparable<YearToMonth>

hashCode

public final int hashCode()
Overrides:
hashCode in class Object

equals

public final boolean equals(Object obj)
Overrides:
equals in class Object

toString

public final String toString()
Overrides:
toString in class Object


Copyright © 2012. All Rights Reserved.