diff options
Diffstat (limited to 'src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java')
-rw-r--r-- | src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java b/src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java index 1e8ec1138e..e2b7b4f8a1 100644 --- a/src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java +++ b/src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java @@ -312,10 +312,10 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta */ public void setDate(int parameterIndex, java.sql.Date x) throws SQLException { - SimpleDateFormat df = new SimpleDateFormat("''yyyy-MM-dd''"); - + 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 @@ -350,8 +350,12 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta * @exception SQLException if a database access error occurs */ public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException - { - set(parameterIndex, "'" + x.toString() + "'"); + { + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + df.setTimeZone(TimeZone.getTimeZone("GMT")); + StringBuffer strBuf = new StringBuffer("'"); + strBuf.append(df.format(x)).append('.').append(x.getNanos()/10000000).append("+00'"); + set(parameterIndex, strBuf.toString()); } /** |