Class YearToSecond
- java.lang.Object
-
- java.lang.Number
-
- org.jooq.types.YearToSecond
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<YearToSecond>,Interval
public final class YearToSecond extends java.lang.Number implements Interval, java.lang.Comparable<YearToSecond>
A combinedYearToMonth/DayToSecondinterval.Some databases (e.g. PostgreSQL) allow for mixing
YEAR TO MONTHandDAY TO SECONDintervals, despite the many questions such a combination raises. TheYearToSecondtype intends to model such vendor specific intervals.The numeric value of this interval corresponds to its "context free" number of milliseconds. While the
DayToSecondinterval component can provide such a value easily (being independent of time zones, daylight saving times, leap years, or leap seconds), theYearToMonthcomponent 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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description YearToSecond(YearToMonth yearToMonth, DayToSecond dayToSecond)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description YearToSecondabs()Get the absolute value of the interval (set its sign to positive)intcompareTo(YearToSecond that)doubledoubleValue()booleanequals(java.lang.Object obj)floatfloatValue()intgetDays()Get the day-part of this intervalDayToSecondgetDayToSecond()intgetHours()Get the hour-part of this intervalintgetMicro()Get the (truncated) micro-part of this intervalintgetMilli()Get the (truncated) milli-part of this intervalintgetMinutes()Get the minute-part of this intervalintgetMonths()intgetNano()Get the nano-part of this intervalintgetSeconds()Get the second-part of this intervalintgetSign()The sign of the intervalintgetYears()YearToMonthgetYearToMonth()inthashCode()intintValue()longlongValue()YearToSecondneg()Negate the interval (change its sign)java.time.DurationtoDuration()Get a duration representation of this interval.java.lang.StringtoString()static YearToSecondvalueOf(double milli)Load aDoublerepresentation of aINTERVAL YEAR TO SECONDby assuming standard 24 hour days and 60 second minutes.static YearToSecondvalueOf(java.lang.String string)Parse a string representation of aINTERVAL YEAR TO SECONDstatic YearToSecondvalueOf(java.time.Duration duration)Transform aDurationinto aYearToSecondinterval by taking its number of milliseconds.static YearToSecondvalueOf(java.time.Period period)Transform aPeriodinto aYearToSecondinterval.-
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
-
YearToSecond
public YearToSecond(YearToMonth yearToMonth, DayToSecond dayToSecond)
-
-
Method Detail
-
valueOf
public static YearToSecond valueOf(double milli)
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
public static YearToSecond valueOf(java.time.Duration duration)
Transform aDurationinto aYearToSecondinterval by taking its number of milliseconds.
-
toDuration
public final java.time.Duration 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
public static YearToSecond valueOf(java.time.Period period)
Transform aPeriodinto aYearToSecondinterval.
-
valueOf
public static YearToSecond valueOf(java.lang.String string)
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
public final YearToSecond neg()
Description copied from interface:IntervalNegate the interval (change its sign)
-
abs
public final YearToSecond abs()
Description copied from interface:IntervalGet the absolute value of the interval (set its sign to positive)
-
getYearToMonth
public final YearToMonth getYearToMonth()
-
getDayToSecond
public final DayToSecond 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 classjava.lang.Number- See Also:
Number.floatValue()
-
doubleValue
public final double doubleValue()
- Specified by:
doubleValuein interfaceInterval- Specified by:
doubleValuein classjava.lang.Number- See Also:
Number.doubleValue()
-
compareTo
public final int compareTo(YearToSecond that)
- Specified by:
compareToin interfacejava.lang.Comparable<YearToSecond>
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public final java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-