From: Kris Jurka Date: Mon, 17 May 2004 20:38:56 +0000 (+0000) Subject: Fix setting timestamp values with very early year values, like 2, by X-Git-Tag: REL7_4_3~26 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=10a8cc5cc5c252aace51e501372037bbc2f4ac2f;p=thirdparty%2Fpostgresql.git 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. --- 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;