bug in storing date ? - Mailing list pgsql-interfaces

From Martin Kuba
Subject bug in storing date ?
Date
Msg-id 3777ED6B.52E679AB@inet.cz
Whole thread Raw
List pgsql-interfaces
Hi,
I have a problem with storing date. I have Postgresql6.4.2
and Java1.2 on Linux.

This is my code for inserting date to column of type "date":

SimpleDateFormat df = new SimpleDateFormat ("dd.MM.yyyy");
ParsePosition pos = new ParsePosition(0);
java.util.Date udate = df.parse("18.06.1999",pos);
java.sql.Date  sdate = new java.sql.Date(udate.getTime());
...
PreparedStatement pstmt = con.prepareStatement ("INSERT INTO mytable VALUES(?)");
pstmt.setDate(1,sdate);
pstmt.executeUpdate();

The problem is, that I want to insert the date "18.06.1999" but
I get "19.06.1999" when I do "SELECT". I think the problem
is that the date is stored as time with 00:00:00 hours.
Is it a bug in my code, in Postgresql JDBC driver or somewhere else ?

Please help.

Martin Kuba
-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  INET, a.s.                          Mgr. Martin
Kuba
Kralovopolska 139                  e-mail: makub@inet.cz 601 12 Brno                      WWW:
http://www.inet.cz/~makub/CzechRepublic                    tel: +420-5-41242414/33
 
--------------------------------------------------------------------
PGP fingerprint = D8 57 47 E5 36 D2 C1 A1  C3 48 B2 59 00 58 42
27http://wwwkeys.cz.pgp.net:11371/pks/lookup?op=index&search=makub
--------------------------------------------------------------------


pgsql-interfaces by date:

Previous
From: Don Garrett
Date:
Subject: Re: [ADMIN] float4
Next
From: "Trans-Euro I.T Ltd (Stephen Martin)"
Date:
Subject: Visdata