]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix setting timestamp values with very early year values, like 2, by
authorKris Jurka <books@ejurka.com>
Mon, 17 May 2004 20:38:56 +0000 (20:38 +0000)
committerKris Jurka <books@ejurka.com>
Mon, 17 May 2004 20:38:56 +0000 (20:38 +0000)
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.

src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java

index 9ee0047c58733dd1de66a59065c4b184f0630a4f..36e0f89ff6d8e98ddb9c14a023981c795ac5c554 100644 (file)
@@ -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;