I have a weird problem with a Java Gregorian Calendar:
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:S Z");
sdf.setTimeZone(TimeZone.getTimeZone("US/Pacific"));
GregorianCalendar cal1 = new GregorianCalendar(TimeZone.getTimeZone("US/Pacific"));
cal1.setTimeInMillis(1320566400000L);
GregorianCalendar cal2 = new GregorianCalendar(TimeZone.getTimeZone("US/Pacific"));
cal2.setTimeInMillis(1320570000000L);
System.out.println(sdf.format(cal1.getTime()));
System.out.println(sdf.format(cal2.getTime()));
I executed the above given code on a machine with default timezone = US Pacific, but the machine is running in Germany.
The result is the following:
2011-11-06 01:00:00:0 -0700
2011-11-06 01:00:00:0 -0800
I really do not understand, why there is a different time zone in the result... I also tested the code on another machine (default Timezone = GMT) and it works correct.
Do somebody have an idea, why this problem occurs?
Best, Michael