public class VerticaDayTimeInterval
extends com.vertica.dsi.dataengine.utilities.DSITimeSpan
implements java.lang.Cloneable
The JDBC representation of the Vertica INTERVAL DAY TO SECOND
type.
It represents a span of time measured in days, hours, minutes, seconds and nanoseconds.
The JDBC specification does not define first class support for interval
data types. There are no java.sql.Types
type identifiers for intervals,
there is no built in setter on the PreparedStatement
interface and
no built in getter on the ResultSet
interface.
Instead, the Vertica JDBC driver follows the ODBC standard when it can.
Each of the 10 day/time interval ranges is identified by the
ODBC standard SQL type identifier. Those identifiers are recreated as
integer fields in this class, analogous to those defined for the
other data types by java.sql.Types
.
To insert a day/time interval into the database, create an instance
of this class and pass it to PreparedStatement.setObject
,
optionally passing one of the ODBC SQL types defined
by this class as the target type parameter.
To retrieve a VericaDayTimeInterval from the database, select an INTERVAL
DAY TO SECOND
column, call ResultSet.getObject
and cast the result to
a VerticaDayTimeInterval
Modifier and Type | Field and Description |
---|---|
static int |
INTERVAL_DAY
Deprecated.
superseded by
VerticaTypes.INTERVAL_DAY |
static int |
INTERVAL_DAY_TO_HOUR
Deprecated.
superseded by
VerticaTypes.INTERVAL_DAY_TO_HOUR |
static int |
INTERVAL_DAY_TO_MINUTE
Deprecated.
superseded by
VerticaTypes.INTERVAL_DAY_TO_MINUTE |
static int |
INTERVAL_DAY_TO_SECOND
Deprecated.
superseded by
VerticaTypes.INTERVAL_DAY_TO_SECOND |
static int |
INTERVAL_HOUR
Deprecated.
superseded by
VerticaTypes.INTERVAL_HOUR |
static int |
INTERVAL_HOUR_TO_MINUTE
Deprecated.
superseded by
VerticaTypes.INTERVAL_HOUR_TO_MINUTE |
static int |
INTERVAL_HOUR_TO_SECOND
Deprecated.
superseded by
VerticaTypes.INTERVAL_HOUR_TO_SECOND |
static int |
INTERVAL_MINUTE
Deprecated.
superseded by
VerticaTypes.INTERVAL_MINUTE |
static int |
INTERVAL_MINUTE_TO_SECOND
Deprecated.
superseded by
VerticaTypes.INTERVAL_MINUTE_TO_SECOND |
static int |
INTERVAL_SECOND
Deprecated.
superseded by
VerticaTypes.INTERVAL_SECOND |
Constructor and Description |
---|
VerticaDayTimeInterval(int day,
int hour,
int minute,
int second,
int fraction,
int fracPrecision,
boolean isNegative) |
VerticaDayTimeInterval(int type,
int day,
int hour,
int minute,
int second,
int fraction,
int fracPrecision,
boolean isNegative)
Constructs a new VerticaDayTimeInterval.
|
Modifier and Type | Method and Description |
---|---|
VerticaDayTimeInterval |
clone()
Returns a deep copy of this VerticaDayTimeInterval.
|
boolean |
equals(java.lang.Object obj)
Returns true if obj is a VerticaDayTimeInterval
and it represents the same span of time as this interval,
regardless of which units are set.
|
int |
getIntervalType()
Gets the ODBC SQL type identifier for this interval.
|
int |
getPrecision() |
int |
hashCode()
The hash code of an interval is computed first by converting
the value of this interval to a number of nanoseconds.
|
static boolean |
isDayTimeInterval(int type)
A helper method to determine if the provided ODBC interval
subtype identifier corresponds to one of the 10 day/time
intervals that this class is capable of representing.
|
void |
setDay(int day)
Sets the days component of this interval.
|
void |
setFraction(int fraction,
int precision)
Sets the fraction component of this interval.
|
void |
setHour(int hour)
Sets the hours component of this interval.
|
void |
setIsNegative(boolean isNegative)
Sets the sign of this interval.
|
void |
setMinute(int minute)
Sets the minutes component of this interval.
|
void |
setSecond(int second)
Sets the seconds component of this interval.
|
java.lang.String |
toString()
Returns a string representation of this interval.
|
public static final int INTERVAL_DAY
VerticaTypes.INTERVAL_DAY
public static final int INTERVAL_DAY_TO_HOUR
VerticaTypes.INTERVAL_DAY_TO_HOUR
public static final int INTERVAL_DAY_TO_MINUTE
VerticaTypes.INTERVAL_DAY_TO_MINUTE
public static final int INTERVAL_DAY_TO_SECOND
VerticaTypes.INTERVAL_DAY_TO_SECOND
public static final int INTERVAL_HOUR
VerticaTypes.INTERVAL_HOUR
public static final int INTERVAL_HOUR_TO_MINUTE
VerticaTypes.INTERVAL_HOUR_TO_MINUTE
public static final int INTERVAL_HOUR_TO_SECOND
VerticaTypes.INTERVAL_HOUR_TO_SECOND
public static final int INTERVAL_MINUTE
VerticaTypes.INTERVAL_MINUTE
public static final int INTERVAL_MINUTE_TO_SECOND
VerticaTypes.INTERVAL_MINUTE_TO_SECOND
public static final int INTERVAL_SECOND
VerticaTypes.INTERVAL_SECOND
public VerticaDayTimeInterval(int day, int hour, int minute, int second, int fraction, int fracPrecision, boolean isNegative)
public VerticaDayTimeInterval(int type, int day, int hour, int minute, int second, int fraction, int fracPrecision, boolean isNegative)
type
- The ODBC SQL type identifier for this interval.day
- The number of days in this interval. Must be no less than zero.hour
- The number of hours in this interval. Must be no less than zero.minute
- The number of minutes in this interval. Must be no less than zero.second
- The number of seconds in this interval. Must be no less than zero.fraction
- The fractional seconds in this interval. Must be no less than zero.fracPrecision
- The precision of the fractional seconds, 6 or less (database can't store more).isNegative
- True if this interval is negative, false if positive.java.lang.IllegalArgumentException
- If any of the parameters are negative, or if type is not one of the ODBC SQL type identifiers defined by this class.public int getPrecision()
public void setDay(int day)
setDay
in class com.vertica.dsi.dataengine.utilities.DSITimeSpan
day
- A positive number of days.java.lang.IllegalArgumentException
- If day is negative, or if using this many days would cause the interval to overflow.public void setHour(int hour)
setHour
in class com.vertica.dsi.dataengine.utilities.DSITimeSpan
hour
- A positive number of hours.java.lang.IllegalArgumentException
- If hour is negative, or if using this many hours would cause the interval to overflow.public void setMinute(int minute)
setMinute
in class com.vertica.dsi.dataengine.utilities.DSITimeSpan
minute
- A positive number of minutes.java.lang.IllegalArgumentException
- If minute is negative, or if using this many minutes would cause the interval to overflow.public void setSecond(int second)
setSecond
in class com.vertica.dsi.dataengine.utilities.DSITimeSpan
second
- A positive number of seconds.java.lang.IllegalArgumentException
- If second is negative, or if using this many seconds would cause the interval to overflow.public void setFraction(int fraction, int precision)
fraction
- A positive number of microseconds.java.lang.IllegalArgumentException
- If fraction is negative, or if using this many microseconds would cause the interval to overflow.public void setIsNegative(boolean isNegative)
setIsNegative
in class com.vertica.dsi.dataengine.utilities.DSITimeSpan
isNegative
- true if this interval is negative, false otherwise.public int hashCode()
hashCode
in class com.vertica.dsi.dataengine.utilities.DSITimeSpan
public boolean equals(java.lang.Object obj)
equals
in class com.vertica.dsi.dataengine.utilities.DSITimeSpan
obj
- An object to compare.public VerticaDayTimeInterval clone()
new VerticaDayTimeInterval(getIntervalType(), getDay(), getHour(), getMinute(), getSecond(), getFraction(), isNegative())
clone
in class com.vertica.dsi.dataengine.utilities.DSITimeSpan
public java.lang.String toString()
toString
in class com.vertica.dsi.dataengine.utilities.DSITimeSpan
public int getIntervalType()
getIntervalType
in class com.vertica.dsi.dataengine.utilities.DSITimeSpan
public static boolean isDayTimeInterval(int type)
type
- An ODBC interval subtype identifier.