From 83dba648bb33728b575bb40d06a4b79cfb294983 Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Thu, 7 Nov 2024 14:21:18 -0800 Subject: [PATCH] initial commit --- .../tools/cldrconverter/CLDRConverter.java | 11 ++++++- .../share/data/tzdata/tzmappings.override | 32 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 src/java.base/share/data/tzdata/tzmappings.override diff --git a/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java b/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java index 8865e3908ae6b..b3b8d103d1072 100644 --- a/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java +++ b/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java @@ -1242,7 +1242,8 @@ private static Stream zidMapEntry() { private static Stream tzDataLinkEntry() { try { return Files.walk(Paths.get(tzDataDir), 1) - .filter(p -> !Files.isDirectory(p)) + .filter(p -> p.toFile().isFile()) + .filter(p -> p.getFileName().toString().matches("africa|antarctica|asia|australasia|backward|etcetera|europe|northamerica|southamerica")) .flatMap(CLDRConverter::extractLinks) .sorted(); } catch (IOException e) { @@ -1273,8 +1274,16 @@ private static Stream extractLinks(Path tzFile) { // Note: the entries are alphabetically sorted, *except* the "world" region // code, i.e., "001". It should be the last entry for the same windows time // zone name entries. (cf. TimeZone_md.c) + // + // The default entries from CLDR's windowsZones.xml file can be modified + // with /tzmappings.override where mapping overrides + // can be specified. private static void generateWindowsTZMappings() throws Exception { Files.createDirectories(Paths.get(DESTINATION_DIR, "windows", "conf")); + Files.readAllLines(Path.of(tzDataDir, "tzmappings.override")).stream() + .filter(o -> !o.isBlank() && !o.startsWith("#")) + .map(o -> o.trim().split(":")) + .forEach(o -> handlerWinZones.put(o[0] + ":" + o[1] , o[2])); Files.write(Paths.get(DESTINATION_DIR, "windows", "conf", "tzmappings"), handlerWinZones.keySet().stream() .filter(k -> k.endsWith(":001") || diff --git a/src/java.base/share/data/tzdata/tzmappings.override b/src/java.base/share/data/tzdata/tzmappings.override new file mode 100644 index 0000000000000..0f0e0c1372c83 --- /dev/null +++ b/src/java.base/share/data/tzdata/tzmappings.override @@ -0,0 +1,32 @@ +# +# Copyright (c) 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 +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# Extra definitions for Windows /lib/tzmappings file. These entries +# replace the existing (Windows Zone Name):(REGION) entries, or are added +# as new entries + +# Example entries +# Foo Standard Time:US:America/Los_Angeles: +# Bar Standard Time:001:Asia/Tokyo: