/** * INTERNAL: * Get a TIMESTAMPTZ value from a result set. */ public Object getTIMESTAMPTZFromResultSet(ResultSet resultSet, int columnNumber, int type, AbstractSession session) throws java.sql.SQLException { TIMESTAMPTZ tsTZ = (TIMESTAMPTZ)resultSet.getObject(columnNumber); //Need to call timestampValue once here with the connection to avoid null point //exception later when timestampValue is called in converObject() if ((tsTZ != null) && (tsTZ.getLength() != 0)) { Connection connection = getConnection(session, resultSet.getStatement().getConnection()); //Bug#4364359 Add a wrapper to overcome TIMESTAMPTZ not serializable as of jdbc 9.2.0.5 and 10.1.0.2. //It has been fixed in the next version for both streams Timestamp timestampToWrap = tsTZ.timestampValue(connection); TimeZone timezoneToWrap = TIMESTAMPHelper.extractTimeZone(tsTZ.toBytes()); return new TIMESTAMPTZWrapper(timestampToWrap, timezoneToWrap, this.isTimestampInGmt); } return null; }
/** * INTERNAL: * Get a TIMESTAMPTZ value from a result set. */ public Object getTIMESTAMPTZFromResultSet(ResultSet resultSet, int columnNumber, int type, AbstractSession session) throws java.sql.SQLException { TIMESTAMPTZ tsTZ = (TIMESTAMPTZ)resultSet.getObject(columnNumber); //Need to call timestampValue once here with the connection to avoid null point //exception later when timestampValue is called in converObject() if ((tsTZ != null) && (tsTZ.getLength() != 0)) { Connection connection = getConnection(session, resultSet.getStatement().getConnection()); //Bug#4364359 Add a wrapper to overcome TIMESTAMPTZ not serializable as of jdbc 9.2.0.5 and 10.1.0.2. //It has been fixed in the next version for both streams Timestamp timestampToWrap = tsTZ.timestampValue(connection); TimeZone timezoneToWrap = TIMESTAMPHelper.extractTimeZone(tsTZ.toBytes()); return new TIMESTAMPTZWrapper(timestampToWrap, timezoneToWrap, this.isTimestampInGmt); } return null; }
/** * Converts {@link TIMESTAMPTZ} to {@link ZonedDateTime}. * * @param dbData the data from the database to be converted, possibly {@code null} * @return the converted value, possibly {@code null} */ public static ZonedDateTime timestamptzToZonedDateTime(TIMESTAMPTZ dbData) { if (dbData == null) { return null; } byte[] bytes = dbData.toBytes(); OffsetDateTime utc = extractUtc(bytes); if (isFixedOffset(bytes)) { ZoneOffset offset = extractOffset(bytes); return utc.atZoneSameInstant(offset); } else { ZoneId zoneId = extractZoneId(bytes); return utc.atZoneSameInstant(zoneId); } }
/** * Converts {@link TIMESTAMPTZ} to {@link ZonedDateTime}. * * @param dbData the data from the database to be converted, possibly {@code null} * @return the converted value, possibly {@code null} */ public static ZonedDateTime timestamptzToZonedDateTime(TIMESTAMPTZ dbData) { if (dbData == null) { return null; } byte[] bytes = dbData.toBytes(); OffsetDateTime utc = extractUtc(bytes); if (isFixedOffset(bytes)) { ZoneOffset offset = extractOffset(bytes); return utc.atZoneSameInstant(offset); } else { ZoneId zoneId = extractZoneId(bytes); return utc.atZoneSameInstant(zoneId); } }
/** * Converts {@link TIMESTAMPTZ} to {@link OffsetDateTime}. * * @param dbData the data from the database to be converted, possibly {@code null} * @return the converted value, possibly {@code null} */ public static OffsetDateTime timestamptzToOffsetDateTime(TIMESTAMPTZ dbData) { if (dbData == null) { return null; } byte[] bytes = dbData.toBytes(); OffsetDateTime utc = extractUtc(bytes); if (isFixedOffset(bytes)) { ZoneOffset offset = extractOffset(bytes); return utc.withOffsetSameInstant(offset); } else { ZoneId zoneId = extractZoneId(bytes); return utc.atZoneSameInstant(zoneId).toOffsetDateTime(); } }
/** * Converts {@link TIMESTAMPTZ} to {@link OffsetDateTime}. * * @param dbData the data from the database to be converted, possibly {@code null} * @return the converted value, possibly {@code null} */ public static OffsetDateTime timestamptzToOffsetDateTime(TIMESTAMPTZ dbData) { if (dbData == null) { return null; } byte[] bytes = dbData.toBytes(); OffsetDateTime utc = extractUtc(bytes); if (isFixedOffset(bytes)) { ZoneOffset offset = extractOffset(bytes); return utc.withOffsetSameInstant(offset); } else { ZoneId zoneId = extractZoneId(bytes); return utc.atZoneSameInstant(zoneId).toOffsetDateTime(); } }