From: Martin Kuba <makub@inet.cz>
To: pgsql-interfaces@postgreSQL.org <pgsql-interfaces@postgreSQL.org>
Subject: bug in storing date ?
Date: Mon, 28 Jun 1999 23:47:23 +0200
Message-ID: <3777ED6B.52E679AB@inet.cz> (raw)
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/
Czech Republic tel: +420-5-41242414/33
--------------------------------------------------------------------
PGP fingerprint = D8 57 47 E5 36 D2 C1 A1 C3 48 B2 59 00 58 42 27
http://wwwkeys.cz.pgp.net:11371/pks/lookup?op=index&search=makub
--------------------------------------------------------------------
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 using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: makub@inet.cz
Subject: Re: bug in storing date ?
In-Reply-To: <3777ED6B.52E679AB@inet.cz>
* 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