postgresql-jdbc.git / summary / log / commit / refs
commit 19699cdc10cbd02abb396ddbebed5eaed425bd62
Author: Dave Cramer <davecramer@gmail.com>
Date: Tue Sep 29 16:24:34 2015 +0000
cache UTC inside timestamputils
org/postgresql/jdbc2/AbstractJdbc2ResultSet.java | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java b/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
index ae9da3d7..1b970c59 100644
--- a/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
+++ b/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
@@ -115,6 +115,8 @@ public abstract class AbstractJdbc2ResultSet implements BaseResultSet, org.postg
protected abstract ResultSetMetaData createMetaData() throws SQLException;
+ private static final Calendar UTC = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+
public ResultSetMetaData getMetaData() throws SQLException
{
checkClosed();
@@ -488,7 +490,8 @@ public abstract class AbstractJdbc2ResultSet implements BaseResultSet, org.postg
return connection.getTimestampUtils().toDateBin(tz, this_row[col]);
} else if (oid == Oid.TIMESTAMP || oid == Oid.TIMESTAMPTZ) {
// JDBC spec says getDate of Timestamp must be supported
- return connection.getTimestampUtils().convertToDate(getTimestamp(i, Calendar.getInstance(TimeZone.getTimeZone("UTC"))), tz);
+ // don't add offset to the timestamp, convertToDate will add the tz specified
+ return connection.getTimestampUtils().convertToDate(getTimestamp(i, UTC), tz);
} else {
throw new PSQLException (GT.tr("Cannot convert the column of type {0} to requested type {1}.",
new Object[]{Oid.toString(oid), "date"}),
@@ -517,7 +520,8 @@ public abstract class AbstractJdbc2ResultSet implements BaseResultSet, org.postg
return connection.getTimestampUtils().toTimeBin(tz, this_row[col]);
} else if (oid == Oid.TIMESTAMP || oid == Oid.TIMESTAMPTZ) {
// JDBC spec says getTime of Timestamp must be supported
- return connection.getTimestampUtils().convertToTime(getTimestamp(i, cal), tz);
+ // use timestamp at UTC
+ return connection.getTimestampUtils().convertToTime(getTimestamp(i, UTC), tz);
} else {
throw new PSQLException (GT.tr("Cannot convert the column of type {0} to requested type {1}.",
new Object[]{Oid.toString(oid), "time"}),
[parent: 41c2ac010b04]