Re: How to properly convert PostgreSQL timestamp to Java xsd:dateTime

Поиск
Список
Период
Сортировка
От Vladimir Sitnikov
Тема Re: How to properly convert PostgreSQL timestamp to Java xsd:dateTime
Дата
Msg-id CAB=Je-G+5eo2XgvL95N6yp64SQZEYM=u+G+DDhVgbCOVhCa7_g@mail.gmail.com
обсуждение исходный текст
Ответ на Re: How to properly convert PostgreSQL timestamp to Java xsd:dateTime  (Christian Castelli <voodoo81people@gmail.com>)
Список 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

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Christian Castelli
Дата:
Сообщение: Re: How to properly convert PostgreSQL timestamp to Java xsd:dateTime
Следующее
От: "jingzhi.zhang@outlook.com"
Дата:
Сообщение: Re: PrepareStatement.execute() blocked because of long time 'create index' operation, connection leak