As quoted from Justin Deoliveira <[EMAIL PROTECTED]>: > Andrea Aime wrote: > > Now, with the following data in the db: > > dt | timetest | datetest > > -------------------------+--------------+------------ > > 2007-07-02 12:06:37.671 | 15:48:50.531 | 2007-07-04 > > > Hmmm... well i assume that the value in the database is just a date > which does not specify a timezone... so the question is when that date > gets turned into an object in java what happens... because all dates > store a timeszone internally.
Right. In fact, there's a difference between timestamp fields with and without time zones. See: http://www.postgresql.org/docs/8.1/static/datatype-datetime.html for details. It is unclear what converting a (PostgreSQL) "date" type field to java.util.Date or java.sql.Date would actually mean, since a "date" type field does not include a time zone... >From reading the API docs on java.sql.Date: To conform with the definition of SQL DATE, the millisecond values wrapped by a java.sql.Date instance must be 'normalized' by setting the hours, minutes, seconds, and milliseconds to zero in the particular time zone with which the instance is associated. this probably means that you get a date/time of 2007-07-04 00:00:00h in your local time zone (+0200 in Andrea's case [and mine]). > > <topp:datetest>2007-07-03+00:00</topp:datetest> However, this is clearly wrong, as can be seen when you take this field in a round-trip from and to the database: if you store it again, it will probably show up in the database as 2007-07-03. So regardless of the stance you take on *how* 'time zone'-less date/time fields get converted, conversion back and forth should *not* change the stored value in the database. Regards, -- -- Gertjan van Oosten, [EMAIL PROTECTED], West Consulting B.V., +31 15 2191 600 ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Geotools-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-devel
