- All Implemented Interfaces:
- Serializable,- Comparable<YearToMonth>,- Interval
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:
- 
Constructor SummaryConstructorsConstructorDescriptionCreate a new year-month interval.YearToMonth(int years) Create a new year-month interval.YearToMonth(int years, int months) Create a new year-month interval.
- 
Method SummaryModifier and TypeMethodDescriptionfinal YearToMonthabs()Get the absolute value of the interval (set its sign to positive)final intcompareTo(YearToMonth that) final doublefinal booleanfinal floatfinal intfinal intgetSign()The sign of the intervalfinal intgetYears()final inthashCode()final intintValue()final longstatic YearToMonthParse a standard SQL string representation of aINTERVAL MONTH.final YearToMonthneg()Negate the interval (change its sign)final DurationGet a duration representation of this interval.final StringtoString()static YearToMonthParse a string representation of aINTERVAL YEAR TO MONTH.static YearToMonthParse a standard SQL string representation of aINTERVAL YEAR.static YearToMonthyearToMonth(String string) Parse a standard SQL string representation of aINTERVAL YEAR TO MONTH.Methods inherited from class java.lang.NumberbyteValue, shortValueMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jooq.types.IntervalbyteValue, shortValue
- 
Constructor Details- 
YearToMonthpublic YearToMonth()Create a new year-month interval.
- 
YearToMonthpublic YearToMonth(int years) Create a new year-month interval.
- 
YearToMonthpublic YearToMonth(int years, int months) Create a new year-month interval.
 
- 
- 
Method Details- 
valueOfParse a string representation of aINTERVAL YEAR TO MONTH.- Parameters:
- string- A string representation of the form- [+|-][years]-[months]
- Returns:
- The parsed YEAR TO MONTHobject, ornullif the string could not be parsed.
 
- 
yearParse a standard SQL string representation of aINTERVAL YEAR.- Parameters:
- string- A string representation of the form- [+|-][years]
- Returns:
- The parsed YEARobject, ornullif the string could not be parsed.
 
- 
yearToMonthParse a standard SQL string representation of aINTERVAL YEAR TO MONTH.- Parameters:
- string- A string representation of the form- [+|-][years]-[months]
- Returns:
- The parsed YEAR TO MONTHobject, ornullif the string could not be parsed.
 
- 
monthParse a standard SQL string representation of aINTERVAL MONTH.- Parameters:
- string- A string representation of the form- [+|-][months]
- Returns:
- The parsed MONTHobject, ornullif the string could not be parsed.
 
- 
toDurationDescription copied from interface:IntervalGet a duration representation of this interval.There is an obvious Durationrepresentation forDayToSecondintervals. If the interval containsYearMonthinformation, then the corresponding duration will use:- 1 year = 365.25 days
- 1 month = 30 days
 This corresponds to PostgreSQL's EXTRACT(EPOCH FROM my_interval)behaviour.- Specified by:
- toDurationin interface- Interval
 
- 
negDescription copied from interface:IntervalNegate the interval (change its sign)
- 
absDescription copied from interface:IntervalGet the absolute value of the interval (set its sign to positive)
- 
getYearspublic final int getYears()
- 
getMonthspublic final int getMonths()
- 
getSignpublic final int getSign()Description copied from interface:IntervalThe sign of the interval
- 
intValuepublic final int intValue()
- 
longValuepublic final long longValue()
- 
floatValuepublic final float floatValue()- Specified by:
- floatValuein interface- Interval
- Specified by:
- floatValuein class- Number
- See Also:
 
- 
doubleValuepublic final double doubleValue()- Specified by:
- doubleValuein interface- Interval
- Specified by:
- doubleValuein class- Number
- See Also:
 
- 
compareTo- Specified by:
- compareToin interface- Comparable<YearToMonth>
 
- 
hashCodepublic final int hashCode()
- 
equals
- 
toString
 
-