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.
This commit is contained in:
Kris Jurka 2004-05-17 20:38:56 +00:00
parent fedfc5d363
commit 10a8cc5cc5

View 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;