From: dmp <danap@ttc-cmc.net>
To: Dave Cramer <pg@fastcrypt.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: Timestamp vs. Java Date/Timestamp
Date: Wed, 13 Feb 2013 10:26:25 -0700
Message-ID: <511BCCC1.7050404@ttc-cmc.net> (raw)
In-Reply-To: <CADK3HHKPL5YbOVnQoP__E362qzVedgLXOmfDBfBcfzX4Sntp-Q@mail.gmail.com>
References: <1360043227.14635.9.camel@localhost>
<CADK3HHJDvnHzcbEu2CMJ7g_riuMTi6D-=1mdvc+T-9DYEidvJA@mail.gmail.com>
<1360733845.24220.50.camel@localhost>
<CADK3HHKPL5YbOVnQoP__E362qzVedgLXOmfDBfBcfzX4Sntp-Q@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
I agree that more things would break then fix. setDate() should
not be used to fill a PostgreSQL TIMESTAMP data type field.
It is fine to use in the application java.util.Date, but then just
convert it to the TIMESTAMP type for PostgreSQL in setTimeStamp() by
using java.util.Date.getTime(). Insure the format is correct though
with a SimpleDateFormat.
Timestamp With Time Zone, timestamptz, can also be handle exactly the
same way by just using the formatter to include a time zone.
SimpleDateFormat timeStampFormat;
java.sql.Timestamp dateTimeValue;
java.util.Date dateParse;
timeStampFormat = new SimpleDateFormat("yyyy-MM-DD HH:mm:ss z");
dateParse = timeStampFormat.parse("2008-12-30 15:16:08 MST");
dateTimeValue = new java.sql.Timestamp(dateParse.getTime());
prepared_sqlStatement.setTimestamp(i++, dateTimeValue);
danap
Dave Cramer wrote:
> And I think that is the way it will remain. I'm afraid this would break
> way more than it would fix
>
>
>
> Dave Cramer
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
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: danap@ttc-cmc.net, pg@fastcrypt.com
Subject: Re: Timestamp vs. Java Date/Timestamp
In-Reply-To: <511BCCC1.7050404@ttc-cmc.net>
References: <1360043227.14635.9.camel@localhost> <CADK3HHJDvnHzcbEu2CMJ7g_riuMTi6D-=1mdvc+T-9DYEidvJA@mail.gmail.com> <1360733845.24220.50.camel@localhost> <CADK3HHKPL5YbOVnQoP__E362qzVedgLXOmfDBfBcfzX4Sntp-Q@mail.gmail.com> <511BCCC1.7050404@ttc-cmc.net>
* 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