- All Implemented Interfaces:
Serializable
,Comparable<DayToSecond>
,Interval
INTERVAL DAY TO SECOND
data type.
DayToSecond
is a Number
whose Number.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)
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 Summary
ConstructorDescriptionCreate 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
Modifier and TypeMethodDescriptionfinal DayToSecond
abs()
Get the absolute value of the interval (set its sign to positive)final int
compareTo
(DayToSecond that) static DayToSecond
Parse a string representation of aINTERVAL DAY TO HOUR
.static DayToSecond
Parse a string representation of aINTERVAL DAY TO HOUR
.static DayToSecond
dayToMinute
(String string) Parse a string representation of aINTERVAL DAY TO MINUTE
.static DayToSecond
dayToSecond
(String string) Parse a string representation of aINTERVAL DAY TO SECOND
.final double
final boolean
final float
final int
getDays()
Get the day-part of this intervalfinal int
getHours()
Get the hour-part of this intervalfinal int
getMicro()
Get the (truncated) micro-part of this intervalfinal int
getMilli()
Get the (truncated) milli-part of this intervalfinal int
Get the minute-part of this intervalfinal int
getNano()
Get the nano-part of this intervalfinal int
Get the second-part of this intervalfinal int
getSign()
The sign of the intervalfinal double
Get the whole interval in daysfinal double
Get the whole interval in hoursfinal double
Get the whole interval in micro-secondsfinal double
Get the whole interval in milli-secondsfinal double
Get the whole interval in minutesfinal double
Get the whole interval in nano-secondsfinal double
Get the whole interval in secondsfinal int
hashCode()
static DayToSecond
Parse a string representation of aINTERVAL HOUR
.static DayToSecond
hourToMinute
(String string) Parse a string representation of aINTERVAL HOUR TO MINUTE
.static DayToSecond
hourToSecond
(String string) Parse a string representation of aINTERVAL HOUR TO SECOND
.final int
intValue()
final long
static DayToSecond
Parse a string representation of aINTERVAL MINUTE
.static DayToSecond
minuteToSecond
(String string) Parse a string representation of aINTERVAL MINUTE TO SECOND
.final DayToSecond
neg()
Negate the interval (change its sign)static DayToSecond
Parse a string representation of aINTERVAL SECOND
.final Duration
Get a duration representation of this interval.final String
toString()
static DayToSecond
valueOf
(double milli) Load aDouble
representation of aINTERVAL DAY TO SECOND
by assuming standard 24 hour days and 60 second minutes.static DayToSecond
valueOf
(long second, int nanos) Load aDouble
representation of aINTERVAL DAY TO SECOND
by assuming standard 24 hour days and 60 second minutes.static DayToSecond
Parse a string representation of aINTERVAL DAY TO SECOND
.static DayToSecond
Transform aDuration
into aDayToSecond
interval 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 Details
-
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 Details
-
valueOf
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 SECOND
object, ornull
if the string could not be parsed.
-
day
Parse a string representation of aINTERVAL DAY TO HOUR
.- Parameters:
string
- A string representation of the form[+|-][days]
- Returns:
- The parsed
INTERVAL DAY
object, ornull
if the string could not be parsed.
-
dayToHour
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 HOUR
object, ornull
if the string could not be parsed.
-
dayToMinute
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 MINUTE
object, ornull
if the string could not be parsed.
-
dayToSecond
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 MINUTE
object, ornull
if the string could not be parsed.
-
hour
Parse a string representation of aINTERVAL HOUR
.- Parameters:
string
- A string representation of the form[+|-][hours]
- Returns:
- The parsed
INTERVAL HOUR
object, ornull
if the string could not be parsed.
-
hourToMinute
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 MINUTE
object, ornull
if the string could not be parsed.
-
hourToSecond
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 SECOND
object, ornull
if the string could not be parsed.
-
minute
Parse a string representation of aINTERVAL MINUTE
.- Parameters:
string
- A string representation of the form[+|-][minutes]
- Returns:
- The parsed
INTERVAL MINUTE
object, ornull
if the string could not be parsed.
-
minuteToSecond
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 SECOND
object, ornull
if the string could not be parsed.
-
second
Parse a string representation of aINTERVAL SECOND
.- Parameters:
string
- A string representation of the form[+|-][seconds].[fractional seconds]
- Returns:
- The parsed
INTERVAL SECOND
object, ornull
if the string could not be parsed.
-
valueOf
Load aDouble
representation of aINTERVAL DAY TO SECOND
by 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 SECOND
object
-
valueOf
Load aDouble
representation of aINTERVAL DAY TO SECOND
by 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 SECOND
object
-
valueOf
Transform aDuration
into aDayToSecond
interval by taking its number of milliseconds. -
toDuration
Description copied from interface:Interval
Get a duration representation of this interval.There is an obvious
Duration
representation forDayToSecond
intervals. If the interval containsYearMonth
information, 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:
toDuration
in interfaceInterval
-
intValue
public final int intValue() -
longValue
public final long longValue() -
floatValue
public final float floatValue()- Specified by:
floatValue
in interfaceInterval
- Specified by:
floatValue
in classNumber
- See Also:
-
doubleValue
public final double doubleValue()- Specified by:
doubleValue
in interfaceInterval
- Specified by:
doubleValue
in classNumber
- See Also:
-
neg
Description copied from interface:Interval
Negate the interval (change its sign) -
abs
Description copied from interface:Interval
Get 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:Interval
The sign of the interval -
compareTo
- Specified by:
compareTo
in interfaceComparable<DayToSecond>
-
hashCode
public final int hashCode() -
equals
-
toString
-