Hi Thomas! Yes you are right and I' wrong ;-) => It's java.sql.Date and not java.util.Date.
*What you might want to do is use getTimestamp() instead.* getTimestamp() looks much better. *But why do you use internal classes of the database engine?* I don't use the internal classes in my application. I only set the value of a java.sql.TIMESTAMP colum by PreparedStatement.setObject(int, Object). My Object is the ISO8601 String (e.g. "2012-11-08T12:40:11.156Z") and I have the problem that if I select the column again, the "outcoming" date is not the same as the "incoming" one. So I was looking for the error cause. I wrote a JUnit test for you. There you can see that some strings will be correctly parsed (e.g. '2012-11-08T12:40:11.156Z') and some other ones like '2012-11-06T23:00:00.000Z' will not correctly parsed by the h2database. https://docs.google.com/open?id=0B7P_rknS1TWxQnkzSTZkWDkxWDA It looks like there is a problem if the time in the ISO Strings is set to twelve o'clock at night. Regards Steve Am Donnerstag, 8. November 2012 19:19:42 UTC+1 schrieb Thomas Mueller: > > Hi, > > I didn't run it myself, but ValueTimestamp.getDate() returns a > java.sql.Date (with the time set to 0) not a java.util.Date. What you might > want to do is use getTimestamp() instead. > > But why do you use internal classes of the database engine? > > Regards, > Thomas > > > > On Thu, Nov 8, 2012 at 2:23 PM, Steve <[email protected] <javascript:>>wrote: > >> Hi! >> My database contains a table which contains a java.sql.TIMESTAMP >> column. I found in the h2 databse source the ValueTimestamp.parse(String) >> function and so I tried to set the value of that column bei an ISO 8601 >> String "2012-11-08T12:40:11.156Z". >> I was able to insert the row without any exception but in my opinion is >> the parsed value not correct. >> >> >> org.h2.value.ValueTimestamp.parse("2012-11-08T12:40:11.156Z").getDate() >> --> internal java.util.Date.fasttime: 1352329200000 >> >> >> DatatypeFactory.newInstance().newXMLGregorianCalendar("2012-11-08T12:40:11.156Z").toGregorianCalendar().getTime() >> --> internal java.util.Date.fasttime: 1352378411156 >> >> Am I doing something wrong? Or will this bug fixed by the planned change >> "Support date/time/timestamp as documented in >> http://en.wikipedia.org/wiki/ISO860" >> >> Best Regards, >> Steve >> >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "H2 Database" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/h2-database/-/Mo89yOCxVsAJ. >> To post to this group, send email to [email protected]<javascript:> >> . >> To unsubscribe from this group, send email to >> [email protected] <javascript:>. >> For more options, visit this group at >> http://groups.google.com/group/h2-database?hl=en. >> > > -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To view this discussion on the web visit https://groups.google.com/d/msg/h2-database/-/_57TU4mEgO4J. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.
