mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 14:24:46 +02:00
8340477: Remove JDK1.1 compatible behavior for "EST", "MST", and "HST" time zones
Reviewed-by: iris, jlu, joehw
This commit is contained in:
parent
97c9212842
commit
71583222eb
5 changed files with 9 additions and 284 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 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
|
||||
|
@ -593,15 +593,6 @@ public abstract class TimeZone implements Serializable, Cloneable {
|
|||
// delegate to default TZ which is effectively immutable
|
||||
return defaultZone.toZoneId();
|
||||
}
|
||||
// derive it ourselves
|
||||
if (ZoneInfoFile.useOldMapping() && id.length() == 3) {
|
||||
if ("EST".equals(id))
|
||||
return ZoneId.of("America/New_York");
|
||||
if ("MST".equals(id))
|
||||
return ZoneId.of("America/Denver");
|
||||
if ("HST".equals(id))
|
||||
return ZoneId.of("America/Honolulu");
|
||||
}
|
||||
return ZoneId.of(id, ZoneId.SHORT_IDS);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ import java.io.StreamCorruptedException;
|
|||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -43,14 +44,12 @@ import java.util.Calendar;
|
|||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.SimpleTimeZone;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.zip.CRC32;
|
||||
|
||||
import jdk.internal.util.StaticProperty;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
/**
|
||||
* Loads TZDB time-zone rules for j.u.TimeZone
|
||||
|
@ -65,19 +64,12 @@ public final class ZoneInfoFile {
|
|||
* @return a set of time zone IDs.
|
||||
*/
|
||||
public static String[] getZoneIds() {
|
||||
int len = regions.length + oldMappings.length;
|
||||
if (!USE_OLDMAPPING) {
|
||||
len += 3; // EST/HST/MST not in tzdb.dat
|
||||
}
|
||||
var shortIDs = ZoneId.SHORT_IDS.keySet();
|
||||
int len = regions.length + shortIDs.size();
|
||||
String[] ids = Arrays.copyOf(regions, len);
|
||||
int i = regions.length;
|
||||
if (!USE_OLDMAPPING) {
|
||||
ids[i++] = "EST";
|
||||
ids[i++] = "HST";
|
||||
ids[i++] = "MST";
|
||||
}
|
||||
for (int j = 0; j < oldMappings.length; j++) {
|
||||
ids[i++] = oldMappings[j][0];
|
||||
for (var id : shortIDs) {
|
||||
ids[i++] = id;
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
@ -216,42 +208,7 @@ public final class ZoneInfoFile {
|
|||
private static String[] regions;
|
||||
private static int[] indices;
|
||||
|
||||
// Flag for supporting JDK backward compatible IDs, such as "EST".
|
||||
private static final boolean USE_OLDMAPPING;
|
||||
|
||||
private static final String[][] oldMappings = new String[][] {
|
||||
{ "ACT", "Australia/Darwin" },
|
||||
{ "AET", "Australia/Sydney" },
|
||||
{ "AGT", "America/Argentina/Buenos_Aires" },
|
||||
{ "ART", "Africa/Cairo" },
|
||||
{ "AST", "America/Anchorage" },
|
||||
{ "BET", "America/Sao_Paulo" },
|
||||
{ "BST", "Asia/Dhaka" },
|
||||
{ "CAT", "Africa/Harare" },
|
||||
{ "CNT", "America/St_Johns" },
|
||||
{ "CST", "America/Chicago" },
|
||||
{ "CTT", "Asia/Shanghai" },
|
||||
{ "EAT", "Africa/Addis_Ababa" },
|
||||
{ "ECT", "Europe/Paris" },
|
||||
{ "IET", "America/Indiana/Indianapolis" },
|
||||
{ "IST", "Asia/Kolkata" },
|
||||
{ "JST", "Asia/Tokyo" },
|
||||
{ "MIT", "Pacific/Apia" },
|
||||
{ "NET", "Asia/Yerevan" },
|
||||
{ "NST", "Pacific/Auckland" },
|
||||
{ "PLT", "Asia/Karachi" },
|
||||
{ "PNT", "America/Phoenix" },
|
||||
{ "PRT", "America/Puerto_Rico" },
|
||||
{ "PST", "America/Los_Angeles" },
|
||||
{ "SST", "Pacific/Guadalcanal" },
|
||||
{ "VST", "Asia/Ho_Chi_Minh" },
|
||||
};
|
||||
|
||||
static {
|
||||
String oldmapping = GetPropertyAction
|
||||
.privilegedGetProperty("sun.timezone.ids.oldmapping", "false")
|
||||
.toLowerCase(Locale.ROOT);
|
||||
USE_OLDMAPPING = (oldmapping.equals("yes") || oldmapping.equals("true"));
|
||||
loadTZDB();
|
||||
}
|
||||
|
||||
|
@ -274,24 +231,6 @@ public final class ZoneInfoFile {
|
|||
});
|
||||
}
|
||||
|
||||
private static void addOldMapping() {
|
||||
for (String[] alias : oldMappings) {
|
||||
aliases.put(alias[0], alias[1]);
|
||||
}
|
||||
if (USE_OLDMAPPING) {
|
||||
aliases.put("EST", "America/New_York");
|
||||
aliases.put("MST", "America/Denver");
|
||||
} else {
|
||||
aliases.put("EST", "America/Panama");
|
||||
aliases.put("MST", "America/Phoenix");
|
||||
}
|
||||
aliases.put("HST", "Pacific/Honolulu");
|
||||
}
|
||||
|
||||
public static boolean useOldMapping() {
|
||||
return USE_OLDMAPPING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the rules from a DateInputStream
|
||||
*
|
||||
|
@ -350,7 +289,7 @@ public final class ZoneInfoFile {
|
|||
}
|
||||
}
|
||||
// old us time-zone names
|
||||
addOldMapping();
|
||||
aliases.putAll(ZoneId.SHORT_IDS);
|
||||
}
|
||||
|
||||
/////////////////////////Ser/////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue