From: ow <oneway_111@yahoo.com>
To: pgsql-jdbc@postgresql.org
Cc: books@ejurka.com
Subject: [BUG?] Extreme dates
Date: Mon, 17 May 2004 11:17:33 -0700 (PDT)
Message-ID: <20040517181733.58834.qmail@web60806.mail.yahoo.com> (raw)
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/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: oneway_111@yahoo.com, books@ejurka.com
Subject: Re: [BUG?] Extreme dates
In-Reply-To: <20040517181733.58834.qmail@web60806.mail.yahoo.com>
References: <20040517181733.58834.qmail@web60806.mail.yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox