From: | Vladimir Sitnikov <sitnikov(dot)vladimir(at)gmail(dot)com> |
---|---|
To: | Christian Castelli <voodoo81people(at)gmail(dot)com>, "Campbell, Lance" <lance(at)illinois(dot)edu> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: How to properly convert PostgreSQL timestamp to Java xsd:dateTime |
Date: | 2016-06-08 18:41:49 |
Message-ID: | CAB=Je-G+5eo2XgvL95N6yp64SQZEYM=u+G+DDhVgbCOVhCa7_g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Lance,
The column name "start_timestamp" suggests that you are storing
"point-in-time" kind of timestamps.
The question is: is it "timestamp with time zone" or "timestamp without
time zone"? I think "with time zone" makes things easier.
If the field is "with time zone", then
GregorianCalendar c = new GregorianCalendar();
Timestamp ts = resultSet.getTimestamp("start_timestamp", c); // <-- you'd
better always use calendar-aware methods
c.setTime(ts);
XMLGregorianCalendar xmlStartTimestamp = DatatypeFactory.newInstance().
newXMLGregorianCalendar(c);
... setStartTimestamp(xmlStartTimestamp)
If performance matters, you might want to cache GregorianCalendar &
DatatypeFactory
objects outside of the loop (however note that neither of them is
thread-safe).
Vladimir
>
From | Date | Subject | |
---|---|---|---|
Next Message | javier.diaz.soto | 2016-06-10 09:26:03 | getRefCursor() is deprecated |
Previous Message | Christian Castelli | 2016-06-08 17:33:38 | Re: How to properly convert PostgreSQL timestamp to Java xsd:dateTime |