I just noted that I missed that you actually posted your code in the first mail, and you also use the joda DateTime API. Then my comments were a bit off ;-) See below for some more notes.
On Thu, Feb 4, 2010 at 15:53, xor exor <[email protected]> wrote: > On Thu, Feb 4, 2010 at 6:08 PM, Thomas Müller <[email protected]>wrote: >> c.setTimeZone(TimeZone.getTimeZone("UTC")); > > Tried that also it doesnt work :|. I created a calendar with gmt0 set attrs > and then created a fresh one as you sugested and set all fields and finally > set the timezone. That way when i enter a date 18:00 GMT+2 i got in db 19:00 > GMT+3 how funny is that :) There is no "UTC" timezone ID in java, you should try "Etc/UTC" Also Calendar.getInstance() is very dangerous, as it uses the default timezone of the current JVM (mostly not what you want) Try this: public Calendar getUTCDate(Calendar in) { Calendar out = Calendar.getInstance(TimeZone.getTimeZone("Etc/UTC")); out.setTimeInMillis(in.getTimeInMillis()); return out; } then use it like this (assuming the story.getStartDate() already has the proper user timezone): storyNode.setProperty("startDate", getUTCDate(story.getStartDate())); (there is a setProperty() method that accepts a Calendar as value and saves it right as jcr DATE property). >> But the Calendar methods are a bit dangerous, see also >> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4827490 Yes, one has to know which combinations are safe ;-) The order of calling methods is sometimes important, as not always the internal time will be recalculated... Regards, Alex -- Alexander Klimetschek [email protected]
