Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/java.base/share/classes/sun/util/calendar/ZoneInfo.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -45,14 +45,14 @@
* for the {@link #getOffset(int,int,int,int,int,int) getOffset}
* method that takes Gregorian calendar date fields.
* <p>
* This table covers transitions from 1900 until 2037 (as of version
* 1.4), Before 1900, it assumes that there was no daylight saving
* This table covers transitions from 1900 until 2100 (as of version
* 23), Before 1900, it assumes that there was no daylight saving
* time and the <code>getOffset</code> methods always return the
* {@link #getRawOffset} value. No Local Mean Time is supported. If a
* specified date is beyond the transition table and this time zone is
* supposed to observe daylight saving time in 2037, it delegates
* supposed to observe daylight saving time in 2100, it delegates
* operations to a {@link java.util.SimpleTimeZone SimpleTimeZone}
* object created using the daylight saving time schedule as of 2037.
* object created using the daylight saving time schedule as of 2100.
* <p>
* The date items, transitions, GMT offset(s), etc. are read from a database
* file. See {@link ZoneInfoFile} for details.
Expand Down
26 changes: 14 additions & 12 deletions src/java.base/share/classes/sun/util/calendar/ZoneInfoFile.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -406,16 +406,16 @@ static long readEpochSec(DataInput in) throws IOException {
// ZoneInfo starts with UTC1900
private static final long UTC1900 = -2208988800L;

// ZoneInfo ends with UTC2037
// LocalDateTime.of(2038, 1, 1, 0, 0, 0).toEpochSecond(ZoneOffset.UTC) - 1;
private static final long UTC2037 = 2145916799L;
// ZoneInfo ends with UTC2100
// LocalDateTime.of(2101, 1, 1, 0, 0, 0).toEpochSecond(ZoneOffset.UTC) - 1;
private static final long UTC2100 = 4133980799L;

// ZoneInfo has an ending entry for 2037, this need to be offset by
// ZoneInfo has an ending entry for 2100, this need to be offset by
// a "rawOffset"
// LocalDateTime.of(2037, 1, 1, 0, 0, 0).toEpochSecond(ZoneOffset.UTC));
private static final long LDT2037 = 2114380800L;
// LocalDateTime.of(2100, 1, 1, 0, 0, 0).toEpochSecond(ZoneOffset.UTC);
private static final long LDT2100 = 4102444800L;

//Current time. Used to determine future GMToffset transitions
//Current time. Used to determine future GMT offset transitions
private static final long CURRT = System.currentTimeMillis()/1000;

/**
Expand Down Expand Up @@ -482,7 +482,7 @@ private static ZoneInfo getZoneInfo(String zoneId,

for (; i < savingsInstantTransitions.length; i++) {
long trans = savingsInstantTransitions[i];
if (trans > UTC2037) {
if (trans > UTC2100) {
// no trans beyond LASTYEAR
lastyear = LASTYEAR;
break;
Expand Down Expand Up @@ -629,11 +629,11 @@ private static ZoneInfo getZoneInfo(String zoneId,
}
} else if (nTrans > 0) { // only do this if there is something in table already
if (lastyear < LASTYEAR) {
// ZoneInfo has an ending entry for 2037
// ZoneInfo has an ending entry for 2100
//long trans = OffsetDateTime.of(LASTYEAR, 1, 1, 0, 0, 0, 0,
// ZoneOffset.ofTotalSeconds(rawOffset/1000))
// .toEpochSecond();
long trans = LDT2037 - rawOffset/1000;
long trans = LDT2100 - rawOffset/1000;

int offsetIndex = indexOf(offsets, 0, nOffsets, rawOffset/1000);
if (offsetIndex == nOffsets)
Expand Down Expand Up @@ -814,7 +814,9 @@ private static int getYear(long epochSecond, int offset) {
private static final long DST_MASK = 0xf0L;
private static final int DST_NSHIFT = 4;
private static final int TRANSITION_NSHIFT = 12;
private static final int LASTYEAR = 2037;
// The `last` year that transitions are accounted for. If there are
// rules that go beyond this LASTYEAR, the value needs to be expanded.
private static final int LASTYEAR = 2100;

// from: 0 for offset lookup, 1 for dstsvings lookup
private static int indexOf(int[] offsets, int from, int nOffsets, int offset) {
Expand Down
7 changes: 5 additions & 2 deletions test/jdk/java/util/TimeZone/NegativeDSTTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -37,7 +37,7 @@

/**
* @test
* @bug 8212970
* @bug 8212970 8324065
* @summary Test whether the savings are positive in time zones that have
* negative savings in the source TZ files.
* @run testng NegativeDSTTest
Expand Down Expand Up @@ -81,7 +81,10 @@ private Object[][] negativeDST () {
{CASABLANCA, LocalDate.of(2019, 5, 6), 0, false},
{CASABLANCA, LocalDate.of(2037, 10, 5), 0, false},
{CASABLANCA, LocalDate.of(2037, 11, 16), ONE_HOUR, true},
{CASABLANCA, LocalDate.of(2038, 9, 27), 0, false},
{CASABLANCA, LocalDate.of(2038, 11, 1), ONE_HOUR, true},
{CASABLANCA, LocalDate.of(2087, 3, 31), 0, false},
{CASABLANCA, LocalDate.of(2087, 5, 12), ONE_HOUR, true},
};
}

Expand Down
19 changes: 6 additions & 13 deletions test/jdk/sun/util/calendar/zi/TestZoneInfo310.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -23,7 +23,7 @@

/*
* @test
* @bug 8007572 8008161 8157792 8212970 8224560
* @bug 8007572 8008161 8157792 8212970 8224560 8324065
* @summary Test whether the TimeZone generated from JSR310 tzdb is the same
* as the one from the tz data from javazic
* @modules java.base/sun.util.calendar:+open
Expand Down Expand Up @@ -173,9 +173,9 @@ public static void main(String[] args) throws Throwable {
ZoneInfoOld zi = toZoneInfoOld(TimeZone.getTimeZone(zid));
ZoneInfoOld ziOLD = (ZoneInfoOld)ZoneInfoOld.getTimeZone(zid);
/*
* Temporary ignoring the failing TimeZones which are having zone
* rules defined till year 2037 and/or above and have negative DST
* save time in IANA tzdata. This bug is tracked via JDK-8223388.
* Ignoring the failing TimeZones which have negative DST
* save time in IANA tzdata, as javazic/ZoneInfoOld cannot
* handle the negative DST.
*
* These are the zones/rules that employ negative DST in vanguard
* format (as of 2019a), Palestine added in 2022d:
Expand All @@ -185,11 +185,6 @@ public static void main(String[] args) throws Throwable {
* - Rule "Namibia"
* - Rule "Palestine"
* - Zone "Europe/Prague"
*
* Tehran/Iran rule has rules beyond 2037, in which javazic assumes
* to be the last year. Thus javazic's rule is based on year 2037
* (Mar 20th/Sep 20th are the cutover dates), while the real rule
* has year 2087 where Mar 21st/Sep 21st are the cutover dates.
*/
if (zid.equals("Africa/Casablanca") || // uses "Morocco" rule
zid.equals("Africa/El_Aaiun") || // uses "Morocco" rule
Expand All @@ -198,10 +193,8 @@ public static void main(String[] args) throws Throwable {
zid.equals("Europe/Bratislava") || // link to "Europe/Prague"
zid.equals("Europe/Dublin") || // uses "Eire" rule
zid.equals("Europe/Prague") ||
zid.equals("Asia/Tehran") || // last rule mismatch
zid.equals("Asia/Gaza") || // uses "Palestine" rule
zid.equals("Asia/Hebron") || // uses "Palestine" rule
zid.equals("Iran")) { // last rule mismatch
zid.equals("Asia/Hebron")) { // uses "Palestine" rule
continue;
}
if (! zi.equalsTo(ziOLD)) {
Expand Down
10 changes: 5 additions & 5 deletions test/jdk/sun/util/calendar/zi/ZoneInfoOld.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -51,14 +51,14 @@
* for the {@link #getOffset(int,int,int,int,int,int) getOffset}
* method that takes Gregorian calendar date fields.
* <p>
* This table covers transitions from 1900 until 2037 (as of version
* 1.4), Before 1900, it assumes that there was no daylight saving
* This table covers transitions from 1900 until 2100 (as of version
* 23), Before 1900, it assumes that there was no daylight saving
* time and the <code>getOffset</code> methods always return the
* {@link #getRawOffset} value. No Local Mean Time is supported. If a
* specified date is beyond the transition table and this time zone is
* supposed to observe daylight saving time in 2037, it delegates
* supposed to observe daylight saving time in 2100, it delegates
* operations to a {@link java.util.SimpleTimeZone SimpleTimeZone}
* object created using the daylight saving time schedule as of 2037.
* object created using the daylight saving time schedule as of 2100.
* <p>
* The date items, transitions, GMT offset(s), etc. are read from a database
* file. See {@link ZoneInfoFile} for details.
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/sun/util/calendar/zi/Zoneinfo.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -37,7 +37,7 @@
class Zoneinfo {

private static final int minYear = 1900;
private static final int maxYear = 2037;
private static final int maxYear = 2100;
private static final long minTime = Time.getLocalTime(minYear, Month.JANUARY, 1, 0);
private static int startYear = minYear;
private static int endYear = maxYear;
Expand Down