Ticket #6459 (closed defect: fixed)

Bug contains 1 commit(s) | SVN Diffs for #6459

 

Opened 2 years ago

Last modified 5 months ago

ICU4J TimeZone#setDefault messes up historic time zone rules in JDK Calendar

Reported by: yoshito Assigned to: yoshito
Priority: major Milestone: 4.1.1
Component: time_calc Version: Current
Keywords: Cc:
Load: Xref: 6278
Java Version: Operating System:
Project (C/J): ICU4J Weeks: 0.1
Review: emmons

Description

While investigating #6278, I found this design problem.

com.ibm.icu.util.TimeZone#setDefault wraps an instance of ICU TimeZone using JDK adapter class - com.ibm.icu.impl.TimeZoneAdapter, which extends java.util.TimeZone, and set the instance as the default Java TimeZone. However, java.util.TimeZone does not have public APIs which return base offset and DST saving at the given time.

Sun JDK has a private class - sun.util.calendar.ZoneInfo, which support such functionality. java.util.Calendar/java.util.Date calls a JDK private class, which checks if the default TimeZone is a ZoneInfo. If not, use the public TimeZone methods - getRawOffset() and inDaylightTime()/getDSTSavings(). These APIs are inherited from JDK 1.1 and do not support historic rule changes. Thus, if com.ibm.icu.util.TimeZone#setDefault is called, JDK Calendar/Date are no longer able to support historic time zone offsets properly.

To avoid this problem, ICU should probably not call java.util.TimeZone#setDefault with an instance of TimeZone subclass wrapping ICU4J OlsonTimeZone. Instead, just create a matching JDK TimeZone with the Olson zone ID and set it as the JDK's default.

Attachments

Change History

08/01/08 08:57:23 changed by yoshito

  • revw set to emmons.

04/22/09 11:44:31 changed by emmons

  • status changed from new to closed.
  • resolution set to fixed.

Add/Change #6459 (ICU4J TimeZone#setDefault messes up historic time zone rules in JDK Calendar)




Anti spam check: