本文整理汇总了Java中org.hsqldb.HsqlDateTime.getZoneMillis方法的典型用法代码示例。如果您正苦于以下问题:Java HsqlDateTime.getZoneMillis方法的具体用法?Java HsqlDateTime.getZoneMillis怎么用?Java HsqlDateTime.getZoneMillis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hsqldb.HsqlDateTime
的用法示例。
在下文中一共展示了HsqlDateTime.getZoneMillis方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setDate
import org.hsqldb.HsqlDateTime; //导入方法依赖的package包/类
/**
* <!-- start generic documentation -->
* Sets the designated parameter to the given <code>java.sql.Date</code> value,
* using the given <code>Calendar</code> object. The driver uses
* the <code>Calendar</code> object to construct an SQL <code>DATE</code> value,
* which the driver then sends to the database. With
* a <code>Calendar</code> object, the driver can calculate the date
* taking into account a custom timezone. If no
* <code>Calendar</code> object is specified, the driver uses the default
* timezone, which is that of the virtual machine running the application.
* <!-- end generic documentation -->
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value
* @param cal the <code>Calendar</code> object the driver will use
* to construct the date
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>PreparedStatement</code>
* @since JDK 1.2 (JDK 1.1.x developers: read the overview for
* JDBCParameterMetaData)
*/
public synchronized void setDate(int parameterIndex, Date x,
Calendar cal) throws SQLException {
checkSetParameterIndex(parameterIndex, false);
int i = parameterIndex - 1;
if (x == null) {
parameterValues[i] = null;
return;
}
Type outType = parameterTypes[i];
long millis = HsqlDateTime.convertToNormalisedDate(x.getTime(), cal);
int zoneOffset = HsqlDateTime.getZoneMillis(cal, millis);
switch (outType.typeCode) {
case Types.SQL_DATE :
case Types.SQL_TIMESTAMP :
case Types.SQL_TIMESTAMP_WITH_TIME_ZONE :
break;
default :
throw Util.sqlException(ErrorCode.X_42561);
}
parameterValues[i] = new TimestampData((millis + zoneOffset) / 1000);
}
示例2: setTime
import org.hsqldb.HsqlDateTime; //导入方法依赖的package包/类
/**
* <!-- start generic documentation -->
* Sets the designated parameter to the given <code>java.sql.Time</code> value,
* using the given <code>Calendar</code> object. The driver uses
* the <code>Calendar</code> object to construct an SQL <code>TIME</code> value,
* which the driver then sends to the database. With
* a <code>Calendar</code> object, the driver can calculate the time
* taking into account a custom timezone. If no
* <code>Calendar</code> object is specified, the driver uses the default
* timezone, which is that of the virtual machine running the application.
* <!-- end generic documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:</h3> <p>
*
* When a setXXX method is used to set a parameter of type
* TIMESTAMP WITH TIME ZONE or TIME WITH TIME ZONE the time zone (including
* Daylight Saving Time) of the Calendar is used as time zone for the
* value.<p>
*
* </div>
* <!-- end release-specific documentation -->
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value
* @param cal the <code>Calendar</code> object the driver will use
* to construct the time
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>PreparedStatement</code>
* @since JDK 1.2 (JDK 1.1.x developers: read the overview for
* JDBCParameterMetaData)
*/
public synchronized void setTime(int parameterIndex, Time x,
Calendar cal) throws SQLException {
checkSetParameterIndex(parameterIndex, false);
int i = parameterIndex - 1;
if (x == null) {
parameterValues[i] = null;
return;
}
Type outType = parameterTypes[i];
long millis = x.getTime();
int zoneOffset = 0;
if (cal != null) {
zoneOffset = HsqlDateTime.getZoneMillis(cal, millis);
}
switch (outType.typeCode) {
case Types.SQL_TIME :
millis += zoneOffset;
zoneOffset = 0;
// fall through
case Types.SQL_TIME_WITH_TIME_ZONE :
break;
default :
throw Util.sqlException(ErrorCode.X_42561);
}
millis = HsqlDateTime.convertToNormalisedTime(millis);
parameterValues[i] = new TimeData((int) (millis / 1000), 0,
zoneOffset / 1000);
}
示例3: setTime
import org.hsqldb.HsqlDateTime; //导入方法依赖的package包/类
/**
* <!-- start generic documentation -->
* Sets the designated parameter to the given <code>java.sql.Time</code> value,
* using the given <code>Calendar</code> object. The driver uses
* the <code>Calendar</code> object to construct an SQL <code>TIME</code> value,
* which the driver then sends to the database. With
* a <code>Calendar</code> object, the driver can calculate the time
* taking into account a custom timezone. If no
* <code>Calendar</code> object is specified, the driver uses the default
* timezone, which is that of the virtual machine running the application.
* <!-- end generic documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:</h3> <p>
*
* When a setXXX method is used to set a parameter of type
* TIMESTAMP WITH TIME ZONE or TIME WITH TIME ZONE the time zone (including
* Daylight Saving Time) of the Calendar is used as time zone for the
* value.<p>
*
* </div>
* <!-- end release-specific documentation -->
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value
* @param cal the <code>Calendar</code> object the driver will use
* to construct the time
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>PreparedStatement</code>
* @since JDK 1.2 (JDK 1.1.x developers: read the overview for
* JDBCParameterMetaData)
*/
public synchronized void setTime(int parameterIndex, Time x,
Calendar cal) throws SQLException {
checkSetParameterIndex(parameterIndex);
int i = parameterIndex - 1;
if (x == null) {
parameterValues[i] = null;
parameterSet[i] = Boolean.TRUE;
return;
}
Type outType = parameterTypes[i];
long millis = x.getTime();
int zoneOffset = 0;
Calendar calendar = cal == null ? session.getCalendar()
: cal;
millis = HsqlDateTime.convertMillisFromCalendar(calendar, millis);
millis = HsqlDateTime.convertToNormalisedTime(millis);
switch (outType.typeCode) {
case Types.SQL_TIME :
break;
case Types.SQL_TIME_WITH_TIME_ZONE :
zoneOffset = HsqlDateTime.getZoneMillis(calendar, millis);
break;
default :
throw JDBCUtil.sqlException(ErrorCode.X_42561);
}
parameterValues[i] = new TimeData((int) (millis / 1000), 0,
zoneOffset / 1000);
parameterSet[i] = Boolean.TRUE;
}
示例4: setDate
import org.hsqldb.HsqlDateTime; //导入方法依赖的package包/类
/**
* <!-- start generic documentation -->
* Sets the designated parameter to the given <code>java.sql.Date</code> value,
* using the given <code>Calendar</code> object. The driver uses
* the <code>Calendar</code> object to construct an SQL <code>DATE</code> value,
* which the driver then sends to the database. With
* a <code>Calendar</code> object, the driver can calculate the date
* taking into account a custom timezone. If no
* <code>Calendar</code> object is specified, the driver uses the default
* timezone, which is that of the virtual machine running the application.
* <!-- end generic documentation -->
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value
* @param cal the <code>Calendar</code> object the driver will use
* to construct the date
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>PreparedStatement</code>
* @since JDK 1.2 (JDK 1.1.x developers: read the overview for
* JDBCParameterMetaData)
*/
public synchronized void setDate(int parameterIndex, Date x,
Calendar cal) throws SQLException {
checkSetParameterIndex(parameterIndex);
int i = parameterIndex - 1;
if (x == null) {
parameterValues[i] = null;
parameterSet[i] = Boolean.TRUE;
return;
}
Type outType = parameterTypes[i];
Calendar calendar = cal == null ? session.getCalendar()
: cal;
long millis = HsqlDateTime.convertMillisFromCalendar(
session.getCalendarGMT(), calendar, x.getTime());
millis = HsqlDateTime.getNormalisedDate(session.getCalendarGMT(),
millis);
switch (outType.typeCode) {
case Types.SQL_DATE :
case Types.SQL_TIMESTAMP :
parameterValues[i] = new TimestampData(millis / 1000);
break;
case Types.SQL_TIMESTAMP_WITH_TIME_ZONE :
int zoneOffset = HsqlDateTime.getZoneMillis(calendar, millis);
parameterValues[i] = new TimestampData(millis / 1000, 0,
zoneOffset / 1000);
break;
default :
throw JDBCUtil.sqlException(ErrorCode.X_42561);
}
parameterSet[i] = Boolean.TRUE;
}
示例5: setTime
import org.hsqldb.HsqlDateTime; //导入方法依赖的package包/类
/**
* <!-- start generic documentation -->
* Sets the designated parameter to the given <code>java.sql.Time</code> value,
* using the given <code>Calendar</code> object. The driver uses
* the <code>Calendar</code> object to construct an SQL <code>TIME</code> value,
* which the driver then sends to the database. With
* a <code>Calendar</code> object, the driver can calculate the time
* taking into account a custom timezone. If no
* <code>Calendar</code> object is specified, the driver uses the default
* timezone, which is that of the virtual machine running the application.
* <!-- end generic documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:</h3> <p>
*
* When a setXXX method is used to set a parameter of type
* TIMESTAMP WITH TIME ZONE or TIME WITH TIME ZONE the time zone (including
* Daylight Saving Time) of the Calendar is used as time zone for the
* value.<p>
*
* </div>
* <!-- end release-specific documentation -->
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value
* @param cal the <code>Calendar</code> object the driver will use
* to construct the time
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>PreparedStatement</code>
* @since JDK 1.2 (JDK 1.1.x developers: read the overview for
* JDBCParameterMetaData)
*/
public synchronized void setTime(int parameterIndex, Time x,
Calendar cal) throws SQLException {
checkSetParameterIndex(parameterIndex);
int i = parameterIndex - 1;
if (x == null) {
parameterValues[i] = null;
parameterSet[i] = Boolean.TRUE;
return;
}
Type outType = parameterTypes[i];
long millis = x.getTime();
int zoneOffset = 0;
Calendar calendar = cal == null ? session.getCalendar()
: cal;
millis = HsqlDateTime.convertMillisFromCalendar(
session.getCalendarGMT(), calendar, millis);
millis = HsqlDateTime.convertToNormalisedTime(millis,
session.getCalendarGMT());
switch (outType.typeCode) {
case Types.SQL_TIME :
break;
case Types.SQL_TIME_WITH_TIME_ZONE :
zoneOffset = HsqlDateTime.getZoneMillis(calendar, millis);
break;
default :
throw JDBCUtil.sqlException(ErrorCode.X_42561);
}
parameterValues[i] = new TimeData((int) (millis / 1000), 0,
zoneOffset / 1000);
parameterSet[i] = Boolean.TRUE;
}
示例6: getTime
import org.hsqldb.HsqlDateTime; //导入方法依赖的package包/类
/**
* <!-- start generic documentation -->
*
* Retrieves the value of the designated JDBC <code>TIME</code> parameter as a
* <code>java.sql.Time</code> object, using
* the given <code>Calendar</code> object
* to construct the time.
* With a <code>Calendar</code> object, the driver
* can calculate the time taking into account a custom timezone and locale.
* If no <code>Calendar</code> object is specified, the driver uses the
* default timezone and locale.
*
* <!-- end generic documentation -->
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:</h3> <p>
*
* HSQLDB supports this feature. <p>
*
* </div>
* <!-- end release-specific documentation -->
*
* @param parameterIndex the first parameter is 1, the second is 2,
* and so on
* @param cal the <code>Calendar</code> object the driver will use
* to construct the time
* @return the parameter value; if the value is SQL <code>NULL</code>, the result
* is <code>null</code>.
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @see #setTime
* @since JDK 1.2 (JDK 1.1.x developers: read the overview for
* JDBCParameterMetaData)
*/
public synchronized Time getTime(int parameterIndex,
Calendar cal) throws SQLException {
TimeData t = (TimeData) getColumnInType(parameterIndex, Type.SQL_TIME);
if (t == null) {
return null;
}
long millis = t.getSeconds() * 1000;
if (parameterTypes[--parameterIndex].isDateTimeTypeWithZone()) {}
else {
// UTC - calZO == (UTC - sessZO) + (sessionZO - calZO)
if (cal != null) {
int zoneOffset = HsqlDateTime.getZoneMillis(cal, millis);
millis += session.getZoneSeconds() * 1000 - zoneOffset;
}
}
return new Time(millis);
}
示例7: setTimestamp
import org.hsqldb.HsqlDateTime; //导入方法依赖的package包/类
/**
* <!-- start generic documentation -->
* Sets the designated parameter to the given <code>java.sql.Timestamp</code> value,
* using the given <code>Calendar</code> object. The driver uses
* the <code>Calendar</code> object to construct an SQL <code>TIMESTAMP</code> value,
* which the driver then sends to the database. With a
* <code>Calendar</code> object, the driver can calculate the timestamp
* taking into account a custom timezone. If no
* <code>Calendar</code> object is specified, the driver uses the default
* timezone, which is that of the virtual machine running the application.
* <!-- end generic documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:</h3> <p>
*
* When a setXXX method is used to set a parameter of type
* TIMESTAMP WITH TIME ZONE or TIME WITH TIME ZONE the time zone (including
* Daylight Saving Time) of the Calendar is used as time zone.<p>
*
* When this method is used to set a parameter of type TIME or
* TIME WITH TIME ZONE, then the nanosecond value of the Timestamp object
* is used if the TIME parameter accepts fractional seconds.
*
* </div>
* <!-- end release-specific documentation -->
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value
* @param cal the <code>Calendar</code> object the driver will use
* to construct the timestamp
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>PreparedStatement</code>
* @since JDK 1.2 (JDK 1.1.x developers: read the overview for
* JDBCParameterMetaData)
*/
public synchronized void setTimestamp(int parameterIndex, Timestamp x,
Calendar cal) throws SQLException {
checkSetParameterIndex(parameterIndex, false);
int i = parameterIndex - 1;
if (x == null) {
parameterValues[i] = null;
return;
}
Type outType = parameterTypes[i];
long millis = x.getTime();
int zoneOffset = 0;
if (cal != null) {
zoneOffset = HsqlDateTime.getZoneMillis(cal, millis);
}
switch (outType.typeCode) {
case Types.SQL_TIMESTAMP :
millis += zoneOffset;
zoneOffset = 0;
// fall through
case Types.SQL_TIMESTAMP_WITH_TIME_ZONE :
parameterValues[i] = new TimestampData(millis / 1000,
x.getNanos(), zoneOffset / 1000);
break;
case Types.SQL_TIME :
millis += zoneOffset;
zoneOffset = 0;
// fall through
case Types.SQL_TIME_WITH_TIME_ZONE :
parameterValues[i] = new TimeData((int) (millis / 1000),
x.getNanos(), zoneOffset / 1000);
break;
default :
throw Util.sqlException(ErrorCode.X_42561);
}
}
示例8: getTime
import org.hsqldb.HsqlDateTime; //导入方法依赖的package包/类
/**
* <!-- start generic documentation -->
* Retrieves the value of the designated column in the current row
* of this <code>ResultSet</code> object as a <code>java.sql.Time</code>
* object in the Java programming language.
* This method uses the given calendar to construct an appropriate millisecond
* value for the time if the underlying database does not store
* timezone information.
* <!-- end generic documentation -->
* <h3>HSQLDB-Specific Information:</h3> <p>
*
* The JDBC specification for this method is vague. HSQLDB interprets the
* specification as follows:
*
* <ol>
* <li>If the SQL type of the column is WITH TIME ZONE, then the UTC value
* of the returned java.sql.Time object is the UTC of the SQL value without
* modification. In other words, the Calendar object is not used.</li>
* <li>If the SQL type of the column is WITHOUT TIME ZONE, then the UTC
* value of the returned java.sql.Time is correct for the given Calendar
* object.</li>
* <li>If the cal argument is null, it it ignored and the method returns
* the same Object as the method without the Calendar parameter.</li>
* </ol>
* </div>
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param cal the <code>java.util.Calendar</code> object
* to use in constructing the time
* @return the column value as a <code>java.sql.Time</code> object;
* if the value is SQL <code>NULL</code>,
* the value returned is <code>null</code> in the Java programming language
* @exception SQLException if a database access error occurs
* or this method is called on a closed result set
* @since JDK 1.2 (JDK 1.1.x developers: read the overview for
* JDBCResultSet)
*/
public Time getTime(int columnIndex, Calendar cal) throws SQLException {
TimeData t = (TimeData) getColumnInType(columnIndex, Type.SQL_TIME);
if (t == null) {
return null;
}
long millis = t.getSeconds() * 1000;
if (resultMetaData.columnTypes[--columnIndex]
.isDateTimeTypeWithZone()) {}
else {
// UTC - calZO == (UTC - sessZO) + (sessionZO - calZO)
if (cal != null) {
int zoneOffset = HsqlDateTime.getZoneMillis(cal, millis);
millis += session.getZoneSeconds() * 1000 - zoneOffset;
}
}
return new Time(millis);
}
示例9: setDate
import org.hsqldb.HsqlDateTime; //导入方法依赖的package包/类
/**
* <!-- start generic documentation -->
* Sets the designated parameter to the given <code>java.sql.Date</code> value,
* using the given <code>Calendar</code> object. The driver uses
* the <code>Calendar</code> object to construct an SQL <code>DATE</code> value,
* which the driver then sends to the database. With
* a <code>Calendar</code> object, the driver can calculate the date
* taking into account a custom timezone. If no
* <code>Calendar</code> object is specified, the driver uses the default
* timezone, which is that of the virtual machine running the application.
* <!-- end generic documentation -->
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value
* @param cal the <code>Calendar</code> object the driver will use
* to construct the date
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>PreparedStatement</code>
* @since JDK 1.2 (JDK 1.1.x developers: read the overview for
* JDBCParameterMetaData)
*/
public synchronized void setDate(int parameterIndex, Date x,
Calendar cal) throws SQLException {
checkSetParameterIndex(parameterIndex);
int i = parameterIndex - 1;
if (x == null) {
parameterValues[i] = null;
parameterSet[i] = Boolean.TRUE;
return;
}
Type outType = parameterTypes[i];
Calendar calendar = cal == null ? session.getCalendar()
: cal;
long millis = HsqlDateTime.convertMillisFromCalendar(calendar,
x.getTime());
millis = HsqlDateTime.getNormalisedDate(millis);
switch (outType.typeCode) {
case Types.SQL_DATE :
case Types.SQL_TIMESTAMP :
parameterValues[i] = new TimestampData(millis / 1000);
break;
case Types.SQL_TIMESTAMP_WITH_TIME_ZONE :
int zoneOffset = HsqlDateTime.getZoneMillis(calendar, millis);
parameterValues[i] = new TimestampData(millis / 1000, 0,
zoneOffset / 1000);
break;
default :
throw JDBCUtil.sqlException(ErrorCode.X_42561);
}
parameterSet[i] = Boolean.TRUE;
}
示例10: getDate
import org.hsqldb.HsqlDateTime; //导入方法依赖的package包/类
/**
* <!-- start generic documentation -->
*
* Retrieves the value of the designated JDBC <code>DATE</code> parameter as a
* <code>java.sql.Date</code> object, using
* the given <code>Calendar</code> object
* to construct the date.
* With a <code>Calendar</code> object, the driver
* can calculate the date taking into account a custom timezone and locale.
* If no <code>Calendar</code> object is specified, the driver uses the
* default timezone and locale.
*
* <!-- end generic documentation -->
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:</h3> <p>
*
* HSQLDB supports this feature. <p>
*
* </div>
* <!-- end release-specific documentation -->
*
* @param parameterIndex the first parameter is 1, the second is 2,
* and so on
* @param cal the <code>Calendar</code> object the driver will use
* to construct the date
* @return the parameter value. If the value is SQL <code>NULL</code>, the result
* is <code>null</code>.
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @see #setDate
* @since JDK 1.2 (JDK 1.1.x developers: read the overview for
* JDBCParameterMetaData)
*/
public synchronized Date getDate(int parameterIndex,
Calendar cal) throws SQLException {
TimestampData t = (TimestampData) getColumnInType(parameterIndex,
Type.SQL_DATE);
long millis = t.getSeconds() * 1000;
int zoneOffset = HsqlDateTime.getZoneMillis(cal, millis);
return new Date(millis - zoneOffset);
}
示例11: getTimestamp
import org.hsqldb.HsqlDateTime; //导入方法依赖的package包/类
/**
* <!-- start generic documentation -->
*
* Retrieves the value of the designated JDBC <code>TIMESTAMP</code> parameter as a
* <code>java.sql.Timestamp</code> object, using
* the given <code>Calendar</code> object to construct
* the <code>Timestamp</code> object.
* With a <code>Calendar</code> object, the driver
* can calculate the timestamp taking into account a custom timezone and locale.
* If no <code>Calendar</code> object is specified, the driver uses the
* default timezone and locale.
*
* <!-- end generic documentation -->
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:</h3> <p>
*
* HSQLDB supports this feature. <p>
*
* </div>
* <!-- end release-specific documentation -->
*
* @param parameterIndex the first parameter is 1, the second is 2,
* and so on
* @param cal the <code>Calendar</code> object the driver will use
* to construct the timestamp
* @return the parameter value. If the value is SQL <code>NULL</code>, the result
* is <code>null</code>.
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @see #setTimestamp
* @since JDK 1.2 (JDK 1.1.x developers: read the overview for
* JDBCParameterMetaData)
*/
public synchronized Timestamp getTimestamp(int parameterIndex,
Calendar cal) throws SQLException {
TimestampData t = (TimestampData) getColumnInType(parameterIndex,
Type.SQL_TIMESTAMP);
if (t == null) {
return null;
}
long millis = t.getSeconds() * 1000;
if (parameterTypes[--parameterIndex].isDateTimeTypeWithZone()) {}
else {
// UTC - calZO == (UTC - sessZO) + (sessionZO - calZO)
if (cal != null) {
int zoneOffset = HsqlDateTime.getZoneMillis(cal, millis);
millis += session.getZoneSeconds() * 1000 - zoneOffset;
}
}
Timestamp ts = new Timestamp(millis);
ts.setNanos(t.getNanos());
return ts;
}
示例12: getDate
import org.hsqldb.HsqlDateTime; //导入方法依赖的package包/类
/**
* <!-- start generic documentation -->
* Retrieves the value of the designated column in the current row
* of this <code>ResultSet</code> object as a <code>java.sql.Date</code> object
* in the Java programming language.
* This method uses the given calendar to construct an appropriate millisecond
* value for the date if the underlying database does not store
* timezone information.
* <!-- end generic documentation -->
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param cal the <code>java.util.Calendar</code> object
* to use in constructing the date
* @return the column value as a <code>java.sql.Date</code> object;
* if the value is SQL <code>NULL</code>,
* the value returned is <code>null</code> in the Java programming language
* @exception SQLException if a database access error occurs
* or this method is called on a closed result set
* @since JDK 1.2 (JDK 1.1.x developers: read the overview for
* JDBCResultSet)
*/
public Date getDate(int columnIndex, Calendar cal) throws SQLException {
TimestampData t = (TimestampData) getColumnInType(columnIndex,
Type.SQL_DATE);
long millis = t.getSeconds() * 1000;
int zoneOffset = HsqlDateTime.getZoneMillis(cal, millis);
return new Date(millis - zoneOffset);
}
示例13: getTimestamp
import org.hsqldb.HsqlDateTime; //导入方法依赖的package包/类
/**
* <!-- start generic documentation -->
* Retrieves the value of the designated column in the current row
* of this <code>ResultSet</code> object as a <code>java.sql.Timestamp</code> object
* in the Java programming language.
* This method uses the given calendar to construct an appropriate millisecond
* value for the timestamp if the underlying database does not store
* timezone information.
* <!-- end generic documentation -->
* <h3>HSQLDB-Specific Information:</h3> <p>
*
* The JDBC specification for this method is vague. HSQLDB interprets the
* specification as follows:
*
* <ol>
* <li>If the SQL type of the column is WITH TIME ZONE, then the UTC value
* of the returned java.sql.Timestamp object is the UTC of the SQL value
* without modification. In other words, the Calendar object is not used.
* </li>
* <li>If the SQL type of the column is WITHOUT TIME ZONE, then the UTC
* value of the returned java.sql.Timestamp is correct for the given
* Calendar object.</li>
* <li>If the cal argument is null, it it ignored and the method returns
* the same Object as the method without the Calendar parameter.</li>
* </ol>
* </div>
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param cal the <code>java.util.Calendar</code> object
* to use in constructing the timestamp
* @return the column value as a <code>java.sql.Timestamp</code> object;
* if the value is SQL <code>NULL</code>,
* the value returned is <code>null</code> in the Java programming language
* @exception SQLException if a database access error occurs
* or this method is called on a closed result set
* @since JDK 1.2 (JDK 1.1.x developers: read the overview for
* JDBCResultSet)
*/
public Timestamp getTimestamp(int columnIndex,
Calendar cal) throws SQLException {
TimestampData t = (TimestampData) getColumnInType(columnIndex,
Type.SQL_TIMESTAMP);
if (t == null) {
return null;
}
long millis = t.getSeconds() * 1000;
if (resultMetaData.columnTypes[--columnIndex]
.isDateTimeTypeWithZone()) {}
else {
// UTC - calZO == (UTC - sessZO) + (sessionZO - calZO)
if (cal != null) {
int zoneOffset = HsqlDateTime.getZoneMillis(cal, millis);
millis += session.getZoneSeconds() * 1000 - zoneOffset;
}
}
Timestamp ts = new Timestamp(millis);
ts.setNanos(t.getNanos());
return ts;
}