Monday, December 10, 2012

Java Calendar timezone converting to GMT problem

Just create a new Calendar in GMT, set the time in that calendar to the same as the original calendar, and you're done:
gmtCalendar.setTime(userCalendar.getTime());
That should be fine, as the getTime() call returns the instant in time (i.e. a java.util.Date with no associated time zone).
As ever though, if you're doing any significant amount of date/time work in Java you should strongly consider using Joda Time instead.

http://stackoverflow.com/questions/6790664/java-calendar-timezone-converting-to-gmt-problem

No comments:

Post a Comment