JDK-8324065 : Daylight saving information for `Africa/Casablanca` are incorrect
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2024-01-17
  • Updated: 2024-07-10
  • Resolved: 2024-01-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 17 JDK 21 JDK 23 JDK 8
11.0.26-oracleUnresolved 17.0.14-oracleUnresolved 21.0.6-oracleUnresolved 23 b07Fixed 8u441Unresolved
Related Reports
Relates :  
Description
The definition of the `Africa/Casablanca` zone has `1:00` as the standard offset since 10/28/2018, and the rules for the zone has entries beyond the year 2037, such as:

```
Rule	Morocco	2037	only	-	Oct	 4	 3:00	-1:00	-
Rule	Morocco	2037	only	-	Nov	15	 2:00	0	-
Rule	Morocco	2038	only	-	Sep	26	 3:00	-1:00	-
Rule	Morocco	2038	only	-	Oct	31	 2:00	0	-
Rule	Morocco	2039	only	-	Sep	18	 3:00	-1:00	-
Rule	Morocco	2039	only	-	Oct	23	 2:00	0	-
...
Rule	Morocco	2086	only	-	Apr	14	 3:00	-1:00	-  (*)
Rule	Morocco	2086	only	-	May	19	 2:00	0	-
Rule	Morocco	2087	only	-	Mar	30	 3:00	-1:00	-
Rule	Morocco	2087	only	-	May	11	 2:00	0	-
```

So for example, looking at the transition marked with `*`, the following code

```
        var tz = TimeZone.getTimeZone("Africa/Casablanca");
        var zi = tz.toZoneId();

        var i = ZonedDateTime.of(LocalDateTime.of(2086, 4, 14, 2, 59), zi).toInstant();
        var d = Date.from(i);
        System.out.println(zi.getRules().isDaylightSavings(i));
        System.out.println(tz.inDaylightTime(d));
        i = ZonedDateTime.of(LocalDateTime.of(2086, 4, 14, 3, 0), zi).toInstant();
        d = Date.from(i);
        System.out.println(zi.getRules().isDaylightSavings(i));
        System.out.println(tz.inDaylightTime(d));
```
should print:
```
true
true
false
false
```
but current implementation prints:
```
true
true
false
true
```
The cause of this issue was there is the definition of the `last year` as `2037`, and transitions are only considered till that year. This restriction seems to come from the old `zic` implementation, thus no longer applicable to the JDK. The `last year` has to be expanded to some year after 2087, which is the greatest transition year currently existing in the TZDB files.


Comments
Changeset: 0d8543d6 Author: Naoto Sato <naoto@openjdk.org> Date: 2024-01-22 17:15:53 +0000 URL: https://git.openjdk.org/jdk/commit/0d8543d6773a516dad54038070dce507179d0709
22-01-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/17492 Date: 2024-01-18 19:37:33 +0000
18-01-2024