- java.lang.Object
-
- java.lang.Number
-
- org.jooq.types.DayToSecond
-
- All Implemented Interfaces:
Serializable,Comparable<DayToSecond>,Interval
public final class DayToSecond extends Number implements Interval, Comparable<DayToSecond>
An implementation for the SQL standardINTERVAL DAY TO SECONDdata type.DayToSecondis aNumberwhoseNumber.intValue()represents the (truncated) number of milliseconds of the interval,Number.doubleValue()represents the approximative number of milliseconds (including hours, minutes, seconds, nanoseconds) 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)andField.sub(Field)Databases that have been observed to natively supportINTERVALdata types are:These dialects have been observed to partially support
INTERVALdata types in date time arithmetic functions, such asTIMESTAMPADD, andTIMESTAMPDIFF:- Author:
- Lukas Eder
- See Also:
Interval, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DayToSecond()Create a new interval.DayToSecond(int days)Create a new day interval.DayToSecond(int days, int hours)Create a new day-hour interval.DayToSecond(int days, int hours, int minutes)Create a new day-minute interval.DayToSecond(int days, int hours, int minutes, int seconds)Create a new day-second interval.DayToSecond(int days, int hours, int minutes, int seconds, int nano)Create a new day-nanoseconds interval.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DayToSecondabs()Get the absolute value of the interval (set its sign to positive)intcompareTo(DayToSecond that)static DayToSecondday(String string)Parse a string representation of aINTERVAL DAY TO HOUR.static DayToSeconddayToHour(String string)Parse a string representation of aINTERVAL DAY TO HOUR.static DayToSeconddayToMinute(String string)Parse a string representation of aINTERVAL DAY TO MINUTE.static DayToSeconddayToSecond(String string)Parse a string representation of aINTERVAL DAY TO SECOND.doubledoubleValue()booleanequals(Object obj)floatfloatValue()intgetDays()Get the day-part of this intervalintgetHours()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 intervalintgetNano()Get the nano-part of this intervalintgetSeconds()Get the second-part of this intervalintgetSign()The sign of the intervaldoublegetTotalDays()Get the whole interval in daysdoublegetTotalHours()Get the whole interval in hoursdoublegetTotalMicro()Get the whole interval in micro-secondsdoublegetTotalMilli()Get the whole interval in milli-secondsdoublegetTotalMinutes()Get the whole interval in minutesdoublegetTotalNano()Get the whole interval in nano-secondsdoublegetTotalSeconds()Get the whole interval in secondsinthashCode()static DayToSecondhour(String string)Parse a string representation of aINTERVAL HOUR.static DayToSecondhourToMinute(String string)Parse a string representation of aINTERVAL HOUR TO MINUTE.static DayToSecondhourToSecond(String string)Parse a string representation of aINTERVAL HOUR TO SECOND.intintValue()longlongValue()static DayToSecondminute(String string)Parse a string representation of aINTERVAL MINUTE.static DayToSecondminuteToSecond(String string)Parse a string representation of aINTERVAL MINUTE TO SECOND.DayToSecondneg()Negate the interval (change its sign)static DayToSecondsecond(String string)Parse a string representation of aINTERVAL SECOND.DurationtoDuration()Get a duration representation of this interval.StringtoString()static DayToSecondvalueOf(double milli)Load aDoublerepresentation of aINTERVAL DAY TO SECONDby assuming standard 24 hour days and 60 second minutes.static DayToSecondvalueOf(long second, int nanos)Load aDoublerepresentation of aINTERVAL DAY TO SECONDby assuming standard 24 hour days and 60 second minutes.static DayToSecondvalueOf(String string)Parse a string representation of aINTERVAL DAY TO SECOND.static DayToSecondvalueOf(Duration duration)Transform aDurationinto aDayToSecondinterval by taking its number of milliseconds.-
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
-
DayToSecond
public DayToSecond()
Create a new interval.
-
DayToSecond
public DayToSecond(int days)
Create a new day interval.
-
DayToSecond
public DayToSecond(int days, int hours)Create a new day-hour interval.
-
DayToSecond
public DayToSecond(int days, int hours, int minutes)Create a new day-minute interval.
-
DayToSecond
public DayToSecond(int days, int hours, int minutes, int seconds)Create a new day-second interval.
-
DayToSecond
public DayToSecond(int days, int hours, int minutes, int seconds, int nano)Create a new day-nanoseconds interval.
-
-
Method Detail
-
valueOf
public static DayToSecond valueOf(String string)
Parse a string representation of aINTERVAL DAY TO SECOND.- Parameters:
string- A string representation of the form[+|-][days] [hours]:[minutes]:[seconds].[fractional seconds]- Returns:
- The parsed
INTERVAL DAY TO SECONDobject, ornullif the string could not be parsed.
-
day
public static DayToSecond day(String string)
Parse a string representation of aINTERVAL DAY TO HOUR.- Parameters:
string- A string representation of the form[+|-][days]- Returns:
- The parsed
INTERVAL DAYobject, ornullif the string could not be parsed.
-
dayToHour
public static DayToSecond dayToHour(String string)
Parse a string representation of aINTERVAL DAY TO HOUR.- Parameters:
string- A string representation of the form[+|-][days] [hours]- Returns:
- The parsed
INTERVAL DAY TO HOURobject, ornullif the string could not be parsed.
-
dayToMinute
public static DayToSecond dayToMinute(String string)
Parse a string representation of aINTERVAL DAY TO MINUTE.- Parameters:
string- A string representation of the form[+|-][days] [hours]:[minutes]- Returns:
- The parsed
INTERVAL DAY TO MINUTEobject, ornullif the string could not be parsed.
-
dayToSecond
public static DayToSecond dayToSecond(String string)
Parse a string representation of aINTERVAL DAY TO SECOND.- Parameters:
string- A string representation of the form[+|-][days] [hours]:[minutes]:[seconds].[fractional seconds]- Returns:
- The parsed
INTERVAL DAY TO MINUTEobject, ornullif the string could not be parsed.
-
hour
public static DayToSecond hour(String string)
Parse a string representation of aINTERVAL HOUR.- Parameters:
string- A string representation of the form[+|-][hours]- Returns:
- The parsed
INTERVAL HOURobject, ornullif the string could not be parsed.
-
hourToMinute
public static DayToSecond hourToMinute(String string)
Parse a string representation of aINTERVAL HOUR TO MINUTE.- Parameters:
string- A string representation of the form[+|-][hours]:[minutes]- Returns:
- The parsed
INTERVAL HOUR TO MINUTEobject, ornullif the string could not be parsed.
-
hourToSecond
public static DayToSecond hourToSecond(String string)
Parse a string representation of aINTERVAL HOUR TO SECOND.- Parameters:
string- A string representation of the form[+|-][hours]:[minutes]:[seconds].[fractional seconds]- Returns:
- The parsed
INTERVAL HOUR TO SECONDobject, ornullif the string could not be parsed.
-
minute
public static DayToSecond minute(String string)
Parse a string representation of aINTERVAL MINUTE.- Parameters:
string- A string representation of the form[+|-][minutes]- Returns:
- The parsed
INTERVAL MINUTEobject, ornullif the string could not be parsed.
-
minuteToSecond
public static DayToSecond minuteToSecond(String string)
Parse a string representation of aINTERVAL MINUTE TO SECOND.- Parameters:
string- A string representation of the form[+|-][[minutes]:[seconds].[fractional seconds]- Returns:
- The parsed
INTERVAL MINUTE TO SECONDobject, ornullif the string could not be parsed.
-
second
public static DayToSecond second(String string)
Parse a string representation of aINTERVAL SECOND.- Parameters:
string- A string representation of the form[+|-][seconds].[fractional seconds]- Returns:
- The parsed
INTERVAL SECONDobject, ornullif the string could not be parsed.
-
valueOf
public static DayToSecond valueOf(double milli)
Load aDoublerepresentation of aINTERVAL DAY 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 DayToSecond valueOf(long second, int nanos)
Load aDoublerepresentation of aINTERVAL DAY TO SECONDby assuming standard 24 hour days and 60 second minutes.- Parameters:
second- The number of secondsnanos- The number of nano seconds- Returns:
- The loaded
INTERVAL DAY TO SECONDobject
-
valueOf
public static DayToSecond valueOf(Duration duration)
Transform aDurationinto aDayToSecondinterval by taking its number of milliseconds.
-
toDuration
public final 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
-
intValue
public final int intValue()
- Specified by:
intValuein interfaceInterval- Specified by:
intValuein classNumber- See Also:
Number.intValue()
-
longValue
public final long longValue()
- Specified by:
longValuein interfaceInterval- Specified by:
longValuein classNumber- See Also:
Number.longValue()
-
floatValue
public final float floatValue()
- Specified by:
floatValuein interfaceInterval- Specified by:
floatValuein classNumber- See Also:
Number.floatValue()
-
doubleValue
public final double doubleValue()
- Specified by:
doubleValuein interfaceInterval- Specified by:
doubleValuein classNumber- See Also:
Number.doubleValue()
-
neg
public final DayToSecond neg()
Description copied from interface:IntervalNegate the interval (change its sign)
-
abs
public final DayToSecond abs()
Description copied from interface:IntervalGet the absolute value of the interval (set its sign to positive)
-
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
-
getTotalDays
public final double getTotalDays()
Get the whole interval in days
-
getTotalHours
public final double getTotalHours()
Get the whole interval in hours
-
getTotalMinutes
public final double getTotalMinutes()
Get the whole interval in minutes
-
getTotalSeconds
public final double getTotalSeconds()
Get the whole interval in seconds
-
getTotalMilli
public final double getTotalMilli()
Get the whole interval in milli-seconds
-
getTotalMicro
public final double getTotalMicro()
Get the whole interval in micro-seconds
-
getTotalNano
public final double getTotalNano()
Get the whole interval in nano-seconds
-
getSign
public final int getSign()
Description copied from interface:IntervalThe sign of the interval
-
compareTo
public final int compareTo(DayToSecond that)
- Specified by:
compareToin interfaceComparable<DayToSecond>
-
-