Re: Timestamp vs. Java Date/Timestamp
От | dmp |
---|---|
Тема | Re: Timestamp vs. Java Date/Timestamp |
Дата | |
Msg-id | 511BCCC1.7050404@ttc-cmc.net обсуждение исходный текст |
Ответ на | Re: Timestamp vs. Java Date/Timestamp (Dave Cramer <pg@fastcrypt.com>) |
Список | pgsql-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
В списке pgsql-jdbc по дате отправления: