mirror of
https://github.com/postgres/postgres.git
synced 2025-07-11 10:01:57 +03:00
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.
This commit is contained in:
@ -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() + "'");
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user