Calendar has a TimeZone property, but setting or modifying it does not convert the
date and time that the calendar holds to a different timezone. I.e. calendar.getTime() always returns the same set value independent from calendar's time zone.
On the other hand, e.g. calendar.get(Calendar.HOUR) / calendar.get(Calendar.HOUR_OF_DAY) returns the correct hour corresponding to calendar's time zone.
Please, use a DateFormat object with corresponding TimeZone set (GMT/UTC in your case) to
parse/format Calendar /
Date objects, e.g:
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") {{ setTimeZone(TimeZone.getTimeZone("GMT 0")); }};
Calendar calendar = Calendar.getInstance();
System.out.println(String.format("Default TimeZone: %1$s; Current Date: %2$s; Formatted Date to GMT TimeZone: %3$s; Parsed Date from GMT TimeZone: %4$s",
TimeZone.getDefault().getDisplayName(), // 1
calendar.getTime(), // 2
formatter.format(calendar.getTime()), // 3
formatter.parse(formatter.format(calendar.getTime())))); // 4
Prints out in such case:
"Default TimeZone: Eastern European Time; Current
Date: Thu Nov 24 16:46:47 EET 2011; Formatted
Date to GMT TimeZone: 2011-11-24 14:46:47.200+0000; Parsed
Date from GMT TimeZone: Thu Nov 24 16:46:47 EET 2011"
Additionally, we have fixed the issue with @Configurable strategy parameter with java.util.Calendar type which had not been supported.