| java.lang.Object org.apache.derby.iapi.types.DataType org.apache.derby.iapi.types.SQLTime
SQLTime | final public class SQLTime extends DataType implements DateTimeDataValue(Code) | | This contains an instance of a SQL Time
Our current implementation doesn't implement time precision so the fractional
seconds portion of the time is always 0. The default when no time precision
is specified is 0 fractional seconds. A SQL Time without timezone information
is assumed to be in the local time zone. The local time is stored as is
and doesn't change if the timezone changes. This is in conformance with the
SQL99 standard. The SQL92 standard indicates that the time is in GMT and
changes with the timezone. The SQL99 standard clarifies this to allow time without
timezoned to be stored as the local time.
Time is stored as two ints. The first int represents hour, minute, second
and the second represents fractional seconds (currently 0 since we don't support
time precision)
encodedTime = -1 indicates null
PERFORMANCE OPTIMIZATION:
The java.sql.Time object is only instantiated on demand for performance
reasons.
|
Method Summary | |
public int | compare(DataValueDescriptor other) | public boolean | compare(int op, DataValueDescriptor other, boolean orderedNulls, boolean unknownRV) | static int | computeEncodedTime(Calendar cal) | static int | computeEncodedTime(int hour, int minute, int second) | static int | computeEncodedTime(java.util.Date value, Calendar currentCal) | protected static String | encodedTimeToString(int encodedTime) Get the String version from the encodedTime. | public int | estimateMemoryUsage() | public DataValueDescriptor | getClone() | public NumberDataValue | getDate(NumberDataValue result) | int | getEncodedTime() | protected static int | getHour(int encodedTime) | public NumberDataValue | getHours(NumberDataValue result) | public int | getLength() | protected static int | getMinute(int encodedTime) | public NumberDataValue | getMinutes(NumberDataValue result) | public NumberDataValue | getMonth(NumberDataValue result) | protected String | getNationalString(LocaleFinder localeFinder) International version of getString(). | public DataValueDescriptor | getNewNull() | public Object | getObject() | protected static int | getSecond(int encodedTime) | public NumberDataValue | getSeconds(NumberDataValue result) | public String | getString() | public Time | getTime(java.util.Calendar cal) Get the time value
Since this is a JDBC object we use the JDBC definition
we use the JDBC definition, see JDBC API Tutorial and Reference
section 47.3.12
Date is set to Jan. | public Timestamp | getTimestamp(Calendar cal) Convert a SQL TIME to a JDBC java.sql.Timestamp.
Behaviour is to set the date portion of the Timestamp
to the actual current date, which may not match the
SQL CURRENT DATE, which remains fixed for the lifetime
of a SQL statement. | public int | getTypeFormatId() Return my format identifier. | public String | getTypeName() | public NumberDataValue | getYear(NumberDataValue result) | public int | hashCode() | final public boolean | isNull() Check if the value is null. | public void | readExternal(ObjectInput in) | public void | readExternalFromArray(ArrayInputStream in) | public void | restoreToNull() | protected void | setFrom(DataValueDescriptor theValue) | public void | setInto(PreparedStatement ps, int position) Adding this method to ensure that super class' setInto method doesn't get called
that leads to the violation of JDBC spec( untyped nulls ) when batching is turned on. | void | setObject(Object theValue) Set the value from a correctly typed Time object. | public void | setValue(Time value, Calendar cal) | public void | setValue(Timestamp value, Calendar cal) | public void | setValue(String theValue) | public void | setValueFromResultSet(ResultSet resultSet, int colNumber, boolean isNullable) | static void | timeToString(int hour, int minute, int second, StringBuffer sb) | public DateTimeDataValue | timestampAdd(int intervalType, NumberDataValue intervalCount, java.sql.Date currentDate, DateTimeDataValue resultHolder) Add a number of intervals to a datetime value. | public NumberDataValue | timestampDiff(int intervalType, DateTimeDataValue time1, java.sql.Date currentDate, NumberDataValue resultHolder) Finds the difference between two datetime values as a number of intervals. | public String | toString() | public int | typePrecedence() | public void | writeExternal(ObjectOutput out) |
JIS_SEPARATOR | final static char JIS_SEPARATOR(Code) | | |
SQLTime | public SQLTime()(Code) | | no-arg constructor required by Formattable
|
SQLTime | public SQLTime(String timeStr, boolean isJdbcEscape, LocaleFinder localeFinder) throws StandardException(Code) | | Construct a time from a string. The allowed time formats are:
- old ISO and IBM European standard: hh.mm[.ss]
- IBM USA standard: hh[:mm] {AM | PM}
- JIS & current ISO: hh:mm[:ss]
exception: Standard - exception if the syntax is invalid or the value is out of range. |
SQLTime | public SQLTime(String timeStr, boolean isJdbcEscape, LocaleFinder localeFinder, Calendar cal) throws StandardException(Code) | | Construct a time from a string. The allowed time formats are:
- old ISO and IBM European standard: hh.mm[.ss]
- IBM USA standard: hh[:mm] {AM | PM}
- JIS & current ISO: hh:mm[:ss]
exception: Standard - exception if the syntax is invalid or the value is out of range. |
computeEncodedTime | static int computeEncodedTime(Calendar cal) throws StandardException(Code) | | Calculate the encoded time from a Calendar object
encoded time is hour << 16 + min << 8 + sec
this function is also used by SQLTimestamp
Parameters: cal - calendar with time set encoded time exception: StandardException - if the time is not in the DB2 range |
encodedTimeToString | protected static String encodedTimeToString(int encodedTime)(Code) | | Get the String version from the encodedTime.
string value. |
estimateMemoryUsage | public int estimateMemoryUsage()(Code) | | |
getEncodedTime | int getEncodedTime()(Code) | | |
getHour | protected static int getHour(int encodedTime)(Code) | | Get the encoded hour value (may be different than hour value for
current timezone if value encoded in a different timezone)
hour value |
getLength | public int getLength()(Code) | | |
getMinute | protected static int getMinute(int encodedTime)(Code) | | Get the encoded minute value (may be different than the minute value for
current timezone if value encoded in a different timezone)
minute value |
getSecond | protected static int getSecond(int encodedTime)(Code) | | Get the encoded second value (may be different than the second value for
current timezone if value encoded in a different timezone)
second value |
getTime | public Time getTime(java.util.Calendar cal)(Code) | | Get the time value
Since this is a JDBC object we use the JDBC definition
we use the JDBC definition, see JDBC API Tutorial and Reference
section 47.3.12
Date is set to Jan. 1, 1970
The localized time value. |
getTimestamp | public Timestamp getTimestamp(Calendar cal)(Code) | | Convert a SQL TIME to a JDBC java.sql.Timestamp.
Behaviour is to set the date portion of the Timestamp
to the actual current date, which may not match the
SQL CURRENT DATE, which remains fixed for the lifetime
of a SQL statement. JDBC drivers (especially network client drivers)
could not be expected to fetch the CURRENT_DATE SQL value
on every query that involved a TIME value, so the current
date as seen by the JDBC client was picked as the logical behaviour.
See DERBY-1811.
|
hashCode | public int hashCode()(Code) | | |
isNull | final public boolean isNull()(Code) | | Check if the value is null.
Whether or not value is logically null. |
setInto | public void setInto(PreparedStatement ps, int position) throws SQLException, StandardException(Code) | | Adding this method to ensure that super class' setInto method doesn't get called
that leads to the violation of JDBC spec( untyped nulls ) when batching is turned on.
|
timeToString | static void timeToString(int hour, int minute, int second, StringBuffer sb)(Code) | | Convert a time to a JDBC escape format string
Parameters: hour - Parameters: minute - Parameters: second - Parameters: sb - The resulting string is appended to this StringBuffer |
timestampAdd | public DateTimeDataValue timestampAdd(int intervalType, NumberDataValue intervalCount, java.sql.Date currentDate, DateTimeDataValue resultHolder) throws StandardException(Code) | | Add a number of intervals to a datetime value. Implements the JDBC escape TIMESTAMPADD function.
Parameters: intervalType - One of FRAC_SECOND_INTERVAL, SECOND_INTERVAL, MINUTE_INTERVAL, HOUR_INTERVAL,DAY_INTERVAL, WEEK_INTERVAL, MONTH_INTERVAL, QUARTER_INTERVAL, or YEAR_INTERVAL Parameters: intervalCount - The number of intervals to add Parameters: currentDate - Used to convert time to timestamp Parameters: resultHolder - If non-null a DateTimeDataValue that can be used to hold the result. If null thengenerate a new holder startTime + intervalCount intervals, as a timestamp exception: StandardException - |
timestampDiff | public NumberDataValue timestampDiff(int intervalType, DateTimeDataValue time1, java.sql.Date currentDate, NumberDataValue resultHolder) throws StandardException(Code) | | Finds the difference between two datetime values as a number of intervals. Implements the JDBC
TIMESTAMPDIFF escape function.
Parameters: intervalType - One of FRAC_SECOND_INTERVAL, SECOND_INTERVAL, MINUTE_INTERVAL, HOUR_INTERVAL,DAY_INTERVAL, WEEK_INTERVAL, MONTH_INTERVAL, QUARTER_INTERVAL, or YEAR_INTERVAL Parameters: time1 - Parameters: currentDate - Used to convert time to timestamp Parameters: resultHolder - If non-null a NumberDataValue that can be used to hold the result. If null thengenerate a new holder the number of intervals by which this datetime is greater than time1 exception: StandardException - |
Methods inherited from org.apache.derby.iapi.types.DataType | public void checkHostVariable(int declaredLength) throws StandardException(Code)(Java Doc) public Object cloneObject()(Code)(Java Doc) public DataValueDescriptor coalesce(DataValueDescriptor[] argumentsList, DataValueDescriptor returnValue) throws StandardException(Code)(Java Doc) public boolean compare(int op, DataValueDescriptor other, boolean orderedNulls, boolean unknownRV) throws StandardException(Code)(Java Doc) final protected StandardException dataTypeConversion(String targetType)(Code)(Java Doc) public BooleanDataValue equals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code)(Java Doc) public boolean equals(Object other)(Code)(Java Doc) protected static int flip(int operator)(Code)(Java Doc) void genericSetObject(Object theValue) throws StandardException(Code)(Java Doc) public boolean getBoolean() throws StandardException(Code)(Java Doc) public byte getByte() throws StandardException(Code)(Java Doc) public byte[] getBytes() throws StandardException(Code)(Java Doc) public Date getDate(Calendar cal) throws StandardException(Code)(Java Doc) public double getDouble() throws StandardException(Code)(Java Doc) public float getFloat() throws StandardException(Code)(Java Doc) public int getInt() throws StandardException(Code)(Java Doc) public long getLong() throws StandardException(Code)(Java Doc) protected String getNationalString(LocaleFinder localeFinder) throws StandardException(Code)(Java Doc) public Object getObject() throws StandardException(Code)(Java Doc) public short getShort() throws StandardException(Code)(Java Doc) public InputStream getStream() throws StandardException(Code)(Java Doc) public Time getTime(Calendar cal) throws StandardException(Code)(Java Doc) public Timestamp getTimestamp(Calendar cal) throws StandardException(Code)(Java Doc) public String getTraceString() throws StandardException(Code)(Java Doc) String getTypeName(String className)(Code)(Java Doc) public BooleanDataValue greaterOrEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code)(Java Doc) public BooleanDataValue greaterThan(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code)(Java Doc) public BooleanDataValue in(DataValueDescriptor left, DataValueDescriptor[] inList, boolean orderedList) throws StandardException(Code)(Java Doc) final protected StandardException invalidFormat()(Code)(Java Doc) final public BooleanDataValue isNotNull()(Code)(Java Doc) final public BooleanDataValue isNullOp()(Code)(Java Doc) public BooleanDataValue lessOrEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code)(Java Doc) public BooleanDataValue lessThan(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code)(Java Doc) public void normalize(DataTypeDescriptor desiredType, DataValueDescriptor source) throws StandardException(Code)(Java Doc) public BooleanDataValue notEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code)(Java Doc) final protected StandardException outOfRange()(Code)(Java Doc) public void setBigDecimal(Number bigDecimal) throws StandardException(Code)(Java Doc) protected void setFrom(DataValueDescriptor dvd) throws StandardException(Code)(Java Doc) public void setInto(PreparedStatement ps, int position) throws SQLException, StandardException(Code)(Java Doc) public void setInto(ResultSet rs, int position) throws SQLException, StandardException(Code)(Java Doc) void setObject(Object theValue) throws StandardException(Code)(Java Doc) public void setObjectForCast(Object theValue, boolean instanceOfResultType, String resultTypeClassName) throws StandardException(Code)(Java Doc) public void setToNull()(Code)(Java Doc) public void setValue(Time theValue) throws StandardException(Code)(Java Doc) public void setValue(Time theValue, Calendar cal) throws StandardException(Code)(Java Doc) public void setValue(Timestamp theValue) throws StandardException(Code)(Java Doc) public void setValue(Timestamp theValue, Calendar cal) throws StandardException(Code)(Java Doc) public void setValue(Date theValue) throws StandardException(Code)(Java Doc) public void setValue(Date theValue, Calendar cal) throws StandardException(Code)(Java Doc) public void setValue(String theValue) throws StandardException(Code)(Java Doc) public void setValue(int theValue) throws StandardException(Code)(Java Doc) public void setValue(double theValue) throws StandardException(Code)(Java Doc) public void setValue(float theValue) throws StandardException(Code)(Java Doc) public void setValue(short theValue) throws StandardException(Code)(Java Doc) public void setValue(long theValue) throws StandardException(Code)(Java Doc) public void setValue(byte theValue) throws StandardException(Code)(Java Doc) public void setValue(boolean theValue) throws StandardException(Code)(Java Doc) public void setValue(byte[] theValue) throws StandardException(Code)(Java Doc) final public void setValue(DataValueDescriptor dvd) throws StandardException(Code)(Java Doc) public void setValue(InputStream theStream, int valueLength) throws StandardException(Code)(Java Doc) public void throwLangSetMismatch(Object value) throws StandardException(Code)(Java Doc) void throwLangSetMismatch(String argTypeName) throws StandardException(Code)(Java Doc) public int typePrecedence()(Code)(Java Doc) public int typeToBigDecimal() throws StandardException(Code)(Java Doc)
|
|
|