Index: org/postgresql/PGStatement.java =================================================================== RCS file: /cvsroot/jdbc/pgjdbc/org/postgresql/PGStatement.java,v retrieving revision 1.16 diff -u -r1.16 PGStatement.java --- org/postgresql/PGStatement.java 2 Aug 2011 13:40:12 -0000 1.16 +++ org/postgresql/PGStatement.java 25 Sep 2011 12:42:43 -0000 @@ -26,6 +26,8 @@ // -infinity / infinity representation in Java public static final long DATE_POSITIVE_INFINITY = 9223372036825200000l; public static final long DATE_NEGATIVE_INFINITY = -9223372036832400000l; + public static final long DATE_POSITIVE_SMALLER_INFINITY = 185543533774800000l; + public static final long DATE_NEGATIVE_SMALLER_INFINITY = -185543533774800000l; /** Index: org/postgresql/jdbc2/TimestampUtils.java =================================================================== RCS file: /cvsroot/jdbc/pgjdbc/org/postgresql/jdbc2/TimestampUtils.java,v retrieving revision 1.25 diff -u -r1.25 TimestampUtils.java --- org/postgresql/jdbc2/TimestampUtils.java 22 Sep 2011 12:53:25 -0000 1.25 +++ org/postgresql/jdbc2/TimestampUtils.java 25 Sep 2011 12:42:43 -0000 @@ -657,6 +657,13 @@ long secs = toJavaSecs(days * 86400L); long millis = secs * 1000L; int offset = tz.getOffset(millis); + if (millis <= PGStatement.DATE_NEGATIVE_SMALLER_INFINITY) { + millis = PGStatement.DATE_NEGATIVE_INFINITY; + offset = 0; + } else if (millis >= PGStatement.DATE_POSITIVE_SMALLER_INFINITY) { + millis = PGStatement.DATE_POSITIVE_INFINITY; + offset = 0; + } return new Date(millis - offset); }