- All Implemented Interfaces:
Serializable,Comparable<YearToSecond>,Interval
YearToMonth / DayToSecond interval.
Some databases (e.g. PostgreSQL) allow for mixing YEAR TO MONTH
and DAY TO SECOND intervals, despite the many questions such a
combination raises. The YearToSecond type intends to model such
vendor specific intervals.
The numeric value of this interval corresponds to its "context free" number
of milliseconds. While the DayToSecond interval component can provide
such a value easily (being independent of time zones, daylight saving times,
leap years, or leap seconds), the YearToMonth component cannot. The
implemented rules are those of PostgreSQL:
- A day has 86400 seconds
- A month has 30 days
- A year has 365.25 days
- A year has 12 months
Examples:
P11Mhas 330 daysP1Y-1Mhas 330 daysP1Yhas 365.25 daysP1Y1Mhas 396.25 days
- Author:
- Lukas Eder
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal YearToSecondabs()Get the absolute value of the interval (set its sign to positive)final intcompareTo(YearToSecond that) final doublebooleanfinal floatfinal intgetDays()Get the day-part of this intervalfinal DayToSecondfinal intgetHours()Get the hour-part of this intervalfinal intgetMicro()Get the (truncated) micro-part of this intervalfinal intgetMilli()Get the (truncated) milli-part of this intervalfinal intGet the minute-part of this intervalfinal intfinal intgetNano()Get the nano-part of this intervalfinal intGet the second-part of this intervalfinal intgetSign()The sign of the intervalfinal intgetYears()final YearToMonthinthashCode()final intintValue()final longfinal YearToSecondneg()Negate the interval (change its sign)final DurationGet a duration representation of this interval.final StringtoString()static YearToSecondvalueOf(double milli) Load aDoublerepresentation of aINTERVAL YEAR TO SECONDby assuming standard 24 hour days and 60 second minutes.static YearToSecondParse a string representation of aINTERVAL YEAR TO SECONDstatic YearToSecondTransform aDurationinto aYearToSecondinterval by taking its number of milliseconds.static YearToSecondTransform aPeriodinto aYearToSecondinterval.Methods inherited from class java.lang.Number
byteValue, shortValueMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jooq.types.Interval
byteValue, shortValue
-
Constructor Details
-
YearToSecond
-
-
Method Details
-
valueOf
Load aDoublerepresentation of aINTERVAL YEAR TO SECONDby assuming standard 24 hour days and 60 second minutes.- Parameters:
milli- The number of milliseconds as a fractional number- Returns:
- The loaded
INTERVAL DAY TO SECONDobject
-
valueOf
Transform aDurationinto aYearToSecondinterval by taking its number of milliseconds. -
toDuration
Description 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 interfaceInterval
-
valueOf
Transform aPeriodinto aYearToSecondinterval. -
valueOf
Parse a string representation of aINTERVAL YEAR TO SECOND- Parameters:
string- A string representation of the form[+|-][years]-[months] [+|-][days] [hours]:[minutes]:[seconds].[fractional seconds]- Returns:
- The parsed
YEAR TO SECONDobject, ornullif the string could not be parsed.
-
neg
Description copied from interface:IntervalNegate the interval (change its sign) -
abs
Description copied from interface:IntervalGet the absolute value of the interval (set its sign to positive) -
getYearToMonth
-
getDayToSecond
-
getYears
public final int getYears() -
getMonths
public final int getMonths() -
getDays
public final int getDays()Get the day-part of this interval -
getHours
public final int getHours()Get the hour-part of this interval -
getMinutes
public final int getMinutes()Get the minute-part of this interval -
getSeconds
public final int getSeconds()Get the second-part of this interval -
getMilli
public final int getMilli()Get the (truncated) milli-part of this interval -
getMicro
public final int getMicro()Get the (truncated) micro-part of this interval -
getNano
public final int getNano()Get the nano-part of this interval -
getSign
public final int getSign()Description copied from interface:IntervalThe sign of the interval -
intValue
public final int intValue() -
longValue
public final long longValue() -
floatValue
public final float floatValue()- Specified by:
floatValuein interfaceInterval- Specified by:
floatValuein classNumber- See Also:
-
doubleValue
public final double doubleValue()- Specified by:
doubleValuein interfaceInterval- Specified by:
doubleValuein classNumber- See Also:
-
compareTo
- Specified by:
compareToin interfaceComparable<YearToSecond>
-
hashCode
public int hashCode() -
equals
-
toString
-