diff options
| author | Bruce Momjian <bruce@momjian.us> | 2001-01-13 18:52:42 +0000 |
|---|---|---|
| committer | Bruce Momjian <bruce@momjian.us> | 2001-01-13 18:52:42 +0000 |
| commit | 0651a5799d836a867a4ea253b265f596971009a6 (patch) | |
| tree | 8bedbe523388a59eed04e8e5c47920cfe40e3338 /src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java | |
| parent | 526427f6d3901274d4058ec411cdfd930e2f1662 (diff) | |
| download | postgresql-0651a5799d836a867a4ea253b265f596971009a6.tar.gz | |
Backed out:
---------------------------------------------------------------------------
Attached is a set of patches for a couple of bugs dealing with
timestamps in JDBC.
Bug#1) Incorrect timestamp stored in DB if client timezone different
than DB.
Diffstat (limited to 'src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java')
| -rw-r--r-- | src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java b/src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java index 24e21c32b8..1e8ec1138e 100644 --- a/src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java +++ b/src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java @@ -310,11 +310,12 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta * @param x the parameter value * @exception SQLException if a database access error occurs */ - private static final SimpleDateFormat DF1 = new SimpleDateFormat("yyyy-MM-dd"); public void setDate(int parameterIndex, java.sql.Date x) throws SQLException { - set(parameterIndex, DF1.format(x)); - + SimpleDateFormat df = new SimpleDateFormat("''yyyy-MM-dd''"); + + set(parameterIndex, df.format(x)); + // The above is how the date should be handled. // // However, in JDK's prior to 1.1.6 (confirmed with the @@ -348,17 +349,9 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta * @param x the parameter value * @exception SQLException if a database access error occurs */ - private static SimpleDateFormat DF2 = getDF2(); - private static SimpleDateFormat getDF2() { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - sdf.setTimeZone(TimeZone.getTimeZone("GMT")); - return sdf; - } public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException - { - StringBuffer strBuf = new StringBuffer("'"); - strBuf.append(DF2.format(x)).append('.').append(x.getNanos()/10000000).append("+00'"); - set(parameterIndex, strBuf.toString()); + { + set(parameterIndex, "'" + x.toString() + "'"); } /** |
