This discussion is archived
0 Replies Latest reply: Mar 13, 2009 4:40 AM by 807575 RSS

TimeZone.equals()

807575 Newbie
Currently Being Moderated
Hello,
after upgrading the JRE on our server to version 1.6.0_12 Calendar comparisons using the equals-method
failed on calendars that were previously considered equal.

Upon investigating the issue it became clear that it had to do with different JRE versions and the TimeZone class,
particularly the ZoneInfo class from SUN.

In Version 1.6.0_11, the ZoneInfo class had a change in its "transitions"-field for the Germany/Berlin TimeZone,
therefore the "checksum"-field of that class now holds a different value, too. This checksum field is used in the
equals-method of the TimeZone class, which in turn is used in the equals-method of the Calendar object.

Now if one creates a Calendar instance on a 1.6.0_10 JRE and compares that to a Calendar that was created
on a 1.6.0_11 JRE (we use RMI heavily), the Calendars are considered to be different, although all the fields of
the calendar are the same and even the TimeZone is (nearly) the same.

Is there any workaround except ignoring the equals-method on Calendars and comparing them using
for instance
calendar1.getTimeInMillis() == calendar2.getTimeInMillis()
or
!calendar1.before(calendar2) && !calendar1.after(calendar2)
?
Forcing our clients to update to 1.6.0_12 is no option for us.. :-/

thanks
Martin