< prev index next >
make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java
Print this page
rev 51713 : [mq]: 8209167
@@ -67,10 +67,11 @@
private static String SPPL_META_SOURCE_FILE;
private static String NUMBERING_SOURCE_FILE;
private static String METAZONES_SOURCE_FILE;
private static String LIKELYSUBTAGS_SOURCE_FILE;
private static String TIMEZONE_SOURCE_FILE;
+ private static String WINZONES_SOURCE_FILE;
static String DESTINATION_DIR = "build/gensrc";
static final String LOCALE_NAME_PREFIX = "locale.displayname.";
static final String LOCALE_SEPARATOR = LOCALE_NAME_PREFIX + "separator";
static final String LOCALE_KEYTYPE = LOCALE_NAME_PREFIX + "keytype";
@@ -89,10 +90,11 @@
static final String PARENT_LOCALE_PREFIX = "parentLocale.";
static final String[] EMPTY_ZONE = {"", "", "", "", "", ""};
private static SupplementDataParseHandler handlerSuppl;
private static LikelySubtagsParseHandler handlerLikelySubtags;
+ private static WinZonesParseHandler handlerWinZones;
static SupplementalMetadataParseHandler handlerSupplMeta;
static NumberingSystemsParseHandler handlerNumbering;
static MetaZonesParseHandler handlerMetaZones;
static TimeZoneParseHandler handlerTimeZone;
private static BundleGenerator bundleGenerator;
@@ -239,10 +241,11 @@
LIKELYSUBTAGS_SOURCE_FILE = CLDR_BASE + "/supplemental/likelySubtags.xml";
NUMBERING_SOURCE_FILE = CLDR_BASE + "/supplemental/numberingSystems.xml";
METAZONES_SOURCE_FILE = CLDR_BASE + "/supplemental/metaZones.xml";
TIMEZONE_SOURCE_FILE = CLDR_BASE + "/bcp47/timezone.xml";
SPPL_META_SOURCE_FILE = CLDR_BASE + "/supplemental/supplementalMetadata.xml";
+ WINZONES_SOURCE_FILE = CLDR_BASE + "/supplemental/windowsZones.xml";
if (BASE_LOCALES.isEmpty()) {
setupBaseLocales("en-US");
}
@@ -253,13 +256,16 @@
parseBCP47();
List<Bundle> bundles = readBundleList();
convertBundles(bundles);
- // Generate java.time.format.ZoneName.java
if (isBaseModule) {
+ // Generate java.time.format.ZoneName.java
generateZoneName();
+
+ // Generate Windows tzmappings
+ generateWindowsTZMappings();
}
}
private static void usage() {
errout("Usage: java CLDRConverter [options]%n"
@@ -430,10 +436,14 @@
// Parse supplementalMetadata
// Currently interested in deprecated time zone ids and language aliases.
handlerSupplMeta = new SupplementalMetadataParseHandler();
parseLDMLFile(new File(SPPL_META_SOURCE_FILE), handlerSupplMeta);
+
+ // Parse windowsZones
+ handlerWinZones = new WinZonesParseHandler();
+ parseLDMLFile(new File(WINZONES_SOURCE_FILE), handlerWinZones);
}
// Parsers for data in "bcp47" directory
//
private static void parseBCP47() throws Exception {
@@ -1086,6 +1096,44 @@
" \"$2\", \"$1\","));
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
+
+ // Generate tzmappings for Windows. The format is:
+ //
+ // (Windows Zone Name):(REGION):(Java TZID)
+ //
+ // where:
+ // Windows Zone Name: arbitrary time zone name string used in Windows
+ // REGION: ISO3166 or UN M.49 code
+ // Java TZID: Java's time zone ID
+ //
+ // 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)
+ private static void generateWindowsTZMappings() throws Exception {
+ Files.createDirectories(Paths.get(DESTINATION_DIR, "windows", "conf"));
+ Files.write(Paths.get(DESTINATION_DIR, "windows", "conf", "tzmappings"),
+ handlerWinZones.keySet().stream()
+ .map(k -> k + ":" + handlerWinZones.get(k) + ":")
+ .sorted(new Comparator<String>() {
+ public int compare(String t1, String t2) {
+ String[] s1 = t1.split(":");
+ String[] s2 = t2.split(":");
+ if (s1[0].equals(s2[0])) {
+ if (s1[1].equals("001")) {
+ return 1;
+ } else if (s2[1].equals("001")) {
+ return -1;
+ } else {
+ return s1[1].compareTo(s2[1]);
+ }
+ } else {
+ return s1[0].compareTo(s2[0]);
+ }
+ }
+ })
+ .collect(Collectors.toList()),
+ StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
+ }
}
< prev index next >