mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 06:14:49 +02:00
8342550: Log warning for using JDK1.1 compatible time zone IDs for future removal
Reviewed-by: jlu, joehw, iris
This commit is contained in:
parent
983e24fd26
commit
cfe70ebcb3
3 changed files with 61 additions and 5 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2025, 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
|
||||
|
@ -46,6 +46,7 @@ import jdk.internal.util.StaticProperty;
|
|||
import sun.util.calendar.ZoneInfo;
|
||||
import sun.util.calendar.ZoneInfoFile;
|
||||
import sun.util.locale.provider.TimeZoneNameUtility;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
/**
|
||||
* {@code TimeZone} represents a time zone offset, and also figures out daylight
|
||||
|
@ -596,6 +597,11 @@ public abstract class TimeZone implements Serializable, Cloneable {
|
|||
}
|
||||
|
||||
private static TimeZone getTimeZone(String ID, boolean fallback) {
|
||||
if (ZoneId.SHORT_IDS.containsKey(ID)) {
|
||||
PlatformLogger.getLogger(TimeZone.class.getName())
|
||||
.warning("Use of the three-letter time zone ID \"%s\" is deprecated and it will be removed in a future release"
|
||||
.formatted(ID));
|
||||
}
|
||||
TimeZone tz = ZoneInfo.getTimeZone(ID);
|
||||
if (tz == null) {
|
||||
tz = parseCustomTimeZone(ID);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, 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
|
||||
|
@ -35,7 +35,8 @@ import java.util.Locale;
|
|||
import java.util.Objects;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import sun.util.calendar.ZoneInfo;
|
||||
import sun.util.calendar.ZoneInfoFile;
|
||||
import sun.util.locale.provider.LocaleProviderAdapter;
|
||||
import sun.util.locale.provider.LocaleResources;
|
||||
|
@ -93,7 +94,7 @@ public class CLDRTimeZoneNameProviderImpl extends TimeZoneNameProviderImpl {
|
|||
case "":
|
||||
// Fill in empty elements
|
||||
deriveFallbackName(namesSuper, i, locale,
|
||||
TimeZone.getTimeZone(id).toZoneId().getRules().isFixedOffset());
|
||||
ZoneInfo.getTimeZone(id).toZoneId().getRules().isFixedOffset());
|
||||
break;
|
||||
case NO_INHERITANCE_MARKER:
|
||||
// CLDR's "no inheritance marker"
|
||||
|
@ -131,7 +132,7 @@ public class CLDRTimeZoneNameProviderImpl extends TimeZoneNameProviderImpl {
|
|||
|
||||
// Derive fallback time zone name according to LDML's logic
|
||||
private void deriveFallbackNames(String[] names, Locale locale) {
|
||||
boolean noDST = TimeZone.getTimeZone(names[0]).toZoneId().getRules().isFixedOffset();
|
||||
boolean noDST = ZoneInfo.getTimeZone(names[0]).toZoneId().getRules().isFixedOffset();
|
||||
|
||||
for (int i = INDEX_STD_LONG; i <= INDEX_GEN_SHORT; i++) {
|
||||
deriveFallbackName(names, i, locale, noDST);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue