X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 1DDB4D1B1B2 for ; Mon, 17 May 2004 15:17:59 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 13124-02 for ; Mon, 17 May 2004 15:17:35 -0300 (ADT) Received: from web60806.mail.yahoo.com (web60806.mail.yahoo.com [216.155.196.69]) by svr1.postgresql.org (Postfix) with SMTP id B6255D1B169 for ; Mon, 17 May 2004 15:17:33 -0300 (ADT) Message-ID: <20040517181733.58834.qmail@web60806.mail.yahoo.com> Received: from [64.81.205.234] by web60806.mail.yahoo.com via HTTP; Mon, 17 May 2004 11:17:33 PDT Date: Mon, 17 May 2004 11:17:33 -0700 (PDT) From: ow Subject: [BUG?] Extreme dates To: pgsql-jdbc@postgresql.org Cc: books@ejurka.com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=FROM_ENDS_IN_NUMS X-Spam-Level: X-Archive-Number: 200405/104 X-Sequence-Number: 10114 Hi, > I've tried to duplicate this and have failed. It does appear that Java is > doing something strange with the date, changing it to 11/30/0002, Probably because months start with 0. > Please try the attached test and see what changes are necessary to get the > failure you describe. The following test illustrates the issue. The output I get is: Row number= 0 col 1= 2030-02-11 14:06:00.828 col 2=2004-05-17 14:06:00.828 public void testKillMe() throws Exception { //--------------- cut here Class.forName("org.postgresql.Driver"); Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/rc","testuser",""); Statement stmt = conn.createStatement(); stmt.executeUpdate("CREATE TEMP TABLE tt (aMin timestamp, aMax timestamp)"); stmt.close(); Calendar cal = Calendar.getInstance(); cal.set(2, 10, 30); // cal.set(0, 0, 0); java.sql.Date d = new java.sql.Date(cal.getTimeInMillis()); System.out.println("Inserting: " + d); PreparedStatement pstmt = conn.prepareStatement("INSERT INTO tt VALUES (?, ?)"); pstmt.setTimestamp(1, new java.sql.Timestamp(d.getTime())); pstmt.setTimestamp(2, new java.sql.Timestamp(System.currentTimeMillis())); pstmt.executeUpdate(); pstmt.close(); stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM tt"); int i = 0; while (rs.next()) { System.out.println("Row number = " + i + " col 1= " + rs.getTimestamp(1) + " col 2=" + rs.getTimestamp(2)); i++; } //--------------- cut here } Thanks __________________________________ Do you Yahoo!? SBC Yahoo! - Internet access at a great low price. http://promo.yahoo.com/sbc/