Search in sources :

Example 6 with TimeData

use of org.hsqldb_voltpatches.types.TimeData in project voltdb by VoltDB.

the class JDBCCallableStatement method getTime.

/**
     * <!-- 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);
}
Also used : TimeData(org.hsqldb_voltpatches.types.TimeData) Time(java.sql.Time) HsqlDateTime(org.hsqldb_voltpatches.HsqlDateTime)

Aggregations

TimeData (org.hsqldb_voltpatches.types.TimeData)6 Time (java.sql.Time)2 HsqlDateTime (org.hsqldb_voltpatches.HsqlDateTime)2 TimestampData (org.hsqldb_voltpatches.types.TimestampData)2 Type (org.hsqldb_voltpatches.types.Type)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 ClobData (org.hsqldb_voltpatches.types.ClobData)1 DateTimeType (org.hsqldb_voltpatches.types.DateTimeType)1 IntervalSecondData (org.hsqldb_voltpatches.types.IntervalSecondData)1 IntervalType (org.hsqldb_voltpatches.types.IntervalType)1