[tz] Problem with some timezone data from 2023 w/ Java SimpleTimeZone

Andreas Haumer andreas at xss.co.at
Wed Jul 19 12:47:30 UTC 2023


[I hope this is the right place to report this problem. I reported
it on OpenSUSE bugzilla, but was asked to report it upstrem, too.
See https://bugzilla.opensuse.org/show_bug.cgi?id=1213470 for my
original bugreport]

A few days ago I found that with the 2023c timezone database as
installed on OpenSUSE LEAP or RedHat Fedora there are two timezones
which produce an IllegalArgumentException in the SimpleTimeZone
Java class (from OpenJDK 17): "Asia/Gaza" and "Asia/Hebron"

The following small Java programm demonstrates the problem:

andreas at localhost:~> cat TimeZoneTest.java
import java.util.TimeZone;

public class TimeZoneTest {
     public static void main(String[] argv) {
         for (final String id : TimeZone.getAvailableIDs())
             try { TimeZone.getTimeZone(id).toString(); }
             catch (Exception ex) { System.out.println("TimeZone " + id + " failed: " + ex); }

Running this programm with a current Java timezone database installed gives the following output:

andreas at localhost:~> java TimeZoneTest.java
TimeZone Asia/Gaza failed: java.lang.IllegalArgumentException: Illegal daylight saving value: 0
TimeZone Asia/Hebron failed: java.lang.IllegalArgumentException: Illegal daylight saving value: 0

andreas at localhost:~> rpm -q timezone-java

andreas at localhost:~> java -version
openjdk version "17.0.7" 2023-04-18
OpenJDK Runtime Environment (build 17.0.7+0-suse-150400.3.24.1-x8664)
OpenJDK 64-Bit Server VM (build 17.0.7+0-suse-150400.3.24.1-x8664, mixed mode, sharing)

This is with OpenSUSE LEAP 15.4 and 15.5
I also see the same exceptions with Fedora 37, which also uses a separate
2023c timezone database for Java.

Debian based systems (like Debian 11, Debian 12 or Ubuntu 22) run the above
program without error. They use the internal tzdb which comes with OpenJDK.

It looks like the timezone database contains a 0 for the dstSavings property.
The constructor for the SimpleTimeZone Java class wants this calue to be > 0
and throws an IllegalArgumentException if it isn't:

     public SimpleTimeZone(int rawOffset, String ID,
                           int startMonth, int startDay, int startDayOfWeek,
                           int startTime, int startTimeMode,
                           int endMonth, int endDay, int endDayOfWeek,
                           int endTime, int endTimeMode,
                           int dstSavings) {

         this.rawOffset = rawOffset;
         this.startMonth = startMonth;
         this.startDay = startDay;
         this.startDayOfWeek = startDayOfWeek;
         this.startTime = startTime;
         this.startTimeMode = startTimeMode;
         this.endMonth = endMonth;
         this.endDay = endDay;
         this.endDayOfWeek = endDayOfWeek;
         this.endTime = endTime;
         this.endTimeMode = endTimeMode;
         this.dstSavings = dstSavings;

         // this.useDaylight is set by decodeRules
         if (dstSavings <= 0) {
             throw new IllegalArgumentException("Illegal daylight saving value: " + dstSavings);

So: is this a problem with the timezone database or rather a problem
with the implementation of the Java SimpleTimeZone class?


- andreas

Andreas Haumer
*x Software + Systeme              | mailto:andreas at xss.co.at
Karmarschgasse 51/2/20             | https://www.xss.co.at/
A-1100 Vienna, Austria             | Tel: +43-1-6060114-0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 203 bytes
Desc: OpenPGP digital signature
URL: <https://mm.icann.org/pipermail/tz/attachments/20230719/1200e2f5/OpenPGP_signature.sig>

More information about the tz mailing list