aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/jdbc
diff options
context:
space:
mode:
authorKris Jurka <books@ejurka.com>2004-05-17 20:38:56 +0000
committerKris Jurka <books@ejurka.com>2004-05-17 20:38:56 +0000
commit10a8cc5cc5c252aace51e501372037bbc2f4ac2f (patch)
treea99d6d50c2d61f6fdf7a66600f82859412090e14 /src/interfaces/jdbc
parentfedfc5d363eb54fa5f25be883a1e54d4a28ea35d (diff)
downloadpostgresql-10a8cc5cc5c252aace51e501372037bbc2f4ac2f.tar.gz
postgresql-10a8cc5cc5c252aace51e501372037bbc2f4ac2f.zip
Fix setting timestamp values with very early year values, like 2, by
formatting all years with four digits. Previously 0002-10-30 was being sent as 2-10-30 which got turned into 2030-02-10. Per report from oneway_111.
Diffstat (limited to 'src/interfaces/jdbc')
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java b/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
index 9ee0047c587..36e0f89ff6d 100644
--- a/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
+++ b/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
@@ -26,7 +26,7 @@ import java.sql.Timestamp;
import java.sql.Types;
import java.util.Vector;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.41.2.5 2004/03/29 17:47:47 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.41.2.6 2004/05/17 20:38:56 jurka Exp $
* This class defines methods of the jdbc1 specification. This class is
* extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2
* methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement
@@ -1267,6 +1267,14 @@ public abstract class AbstractJdbc1Statement implements BaseStatement
//we need to include the local time and timezone offset
//so that timestamp without time zone works correctly
int l_year = x.getYear() + 1900;
+
+ // always use four digits for the year so very
+ // early years, like 2, don't get misinterpreted
+ int l_yearlen = String.valueOf(l_year).length();
+ for (int i=4; i>l_yearlen; i--) {
+ sbuf.append("0");
+ }
+
sbuf.append(l_year);
sbuf.append('-');
int l_month = x.getMonth() + 1;