This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: [PATCH] libjava time zone fixes and improvements
- From: Andrew Haley <aph at redhat dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: java-patches at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Thu, 22 Feb 2007 15:32:58 +0000
- Subject: Re: [PATCH] libjava time zone fixes and improvements
- References: <20070220224800.GH10425@devserv.devel.redhat.com>
Jakub Jelinek writes:
> Hi!
>
> The following patch adds a new class, gnu.java.util.ZoneInfo which
> unlike java.util.SimpleTimeZone can handle historical (and future)
> DST transitions and different offsets and changes to java.util.TimeZone
> to read /usr/share/zoneinfo files to create the TimeZone objects
> preferrably over the builtin simple timezones. The advantage of using
> system tzdata files over including our own files or current hardcoded
> tables (which are only SimpleTimeZone and thus can't describe some rules
> for anything but one year, in other cases e.g. only next year and onwards
> or only last few years correctly) is that no separate step is needed to
> keep libgcj's timezone information up to date (which changes often even
> 20 times a year), while libgcj's own files would mean updating system
> zoneinfo files and libgcj files and the current hardcoded tables mean
> libgcj has to be recompiled.
> In addition to this a bunch of bugs have been fixed:
>
> 1) Date.parse wasn't able to properly parse seconds (and sometimes
> minutes) in strings like:
> Sun Mar 11 03:30:59 2007
> while Sun JDK did the right thing - the number 59 was considered
> to be a year and then overwritten again with 2007, so it got
> parsed like 03:30:00.
> 2) if /etc/localtime is a symlink, try to figure zone name from where
> the symlink points to (PR28550)
> 3) added /etc/sysconfig/clock parsing (PR17002)
> 4) getDefaultTimeZone couldn't properly handle e.g. EST5 or EST5EDT6
> 5) parseTime forgotting minutes if time was with one colon like 12:45
> (would do the right thing for 12 or 12:45:03)
> 6) several SimpleTimeZone bugs, see attached SimpleTimeZoneTest.java
> testcase; e.g. set{Start,End}Rule is documented to set the time
> in WALL_TIME mode, while it was using whatever was the last mode
> set, getOffset didn't properly handle the case when millis + dstSavings
> crossed a day boundary, etc.
>
> TimeZoneTest.java checks in all available time zones the interesting
> times zdump -v computes (second before and second on which each transition
> is made) - can take several minutes, as 550 or so zdump -v calls are quite
> slow (as zdump uses binary searching to find the interesting times).
>
> Ok to commit?
>
> Jakub
> 2007-02-20 Jakub Jelinek <jakub@redhat.com>
>
> libjava/
> PR libgcj/17002
> PR classpath/28550
> * java/util/VMTimeZone.java (getDefaultTimeZoneId): To read
> /etc/localtime, use ZoneInfo.readTZFile instead of
> VMTimeZone.readtzFile. Get better timezone name for /etc/localtime,
> either if it is a symlink or through /etc/sysconfig/clock.
> (readSysconfigClockFile): New static method.
> (readtzFile): Removed.
> * java/lang/System.java: Add gnu.java.util.zoneinfo.dir to comments.
> * posix.cc (_Jv_platform_initProperties): Set
> gnu.java.util.zoneinfo.dir.
> * sources.am (gnu_java_util_source_files): Add
> classpath/gnu/java/util/ZoneInfo.java.
> * Makefile.in: Regenerated.
> * java/util/VMTimeZone.h: Regenerated.
> * java/util/TimeZone.h: Regenerated.
> * gnu/java/util/ZoneInfo.h: Generated.
> libjava/classpath/
> * java/util/Date.java (parse): Properly parse 09:01:02 as
> hours/minutes/seconds, not as hours/minutes/year.
> * java/util/SimpleTimeZone.java (SimpleTimeZone): Simplify
> {start,end}TimeMode constructor by calling shorter constructor,
> set {start,end}TimeMode fields after it returns.
> (setStartRule): Don't adjust startTime into WALL_TIME. Set
> startTimeMode to WALL_TIME.
> (endStartRule): Similarly.
> (getOffset): Handle properly millis + dstOffset overflowing into the
> next day. Adjust startTime resp. endTime based on startTimeMode
> resp. endTimeMode.
> * java/util/TimeZone.java (zoneinfo_dir, availableIDs, aliases0): New
> static fields.
> (timezones): Remove synchronized keyword. Set zoneinfo_dir.
> If non-null, set up aliases0 and don't put anything into
> timezones0.
> (defaultZone): Call getTimeZone instead of timezones().get.
> (getDefaultTimeZone): Fix parsing of EST5 or EST5EDT6. Use
> getTimeZoneInternal instead of timezones().get.
> (parseTime): Parse correctly hour:minute.
> (getTimeZoneInternal): New private method.
> (getTimeZone): Do the custom ID checking first, canonicalize
> ID for custom IDs as required by documentation. Call
> getTimeZoneInternal to handle the rest.
> (getAvailableIDs(int)): Add locking. Handle zoneinfo_dir != null.
> (getAvailableIDs(File,String,ArrayList)): New private method.
> (getAvailableIDs()): Add locking. Handle zoneinfo_dir != null.
> * gnu/java/util/ZoneInfo.java: New file.
OK, thanks.
Andrew.