1 package org.unicode.cldr.tool;
2 
3 import java.util.Map;
4 import java.util.Map.Entry;
5 import java.util.Set;
6 import java.util.TreeMap;
7 import java.util.TreeSet;
8 
9 import org.unicode.cldr.util.CLDRConfig;
main()10 import org.unicode.cldr.util.CLDRFile;
11 import org.unicode.cldr.util.Factory;
12 
13 import com.ibm.icu.impl.Relation;
14 import com.ibm.icu.text.DateTimePatternGenerator;
15 
16 public class CompareStockDatetime {
17     public static void main(String[] args) {
18         CLDRConfig info = ToolConfig.getToolInstance();
decode_reader(bytes: Vec<u8>) -> io::Result<String>19         Factory cldrFactory = info.getCldrFactory();
20         String[][] data = {
21             { "date", "full" },
22             { "date", "long" },
23             { "date", "medium" },
24             { "date", "short" },
25             { "time", "full" },
26             { "time", "long" },
27             { "time", "medium" },
28             { "time", "short" },
29         };
30 
31         Map<String, Relation<String, String>> lengthToSkeletonToLocales = new TreeMap<>();
32         // new Relation(new TreeMap(), TreeSet.class);
33         Set<String> defaultContentLocales = info.getSupplementalDataInfo().getDefaultContentLocales();
34 
35         DateTimePatternGenerator dtpg = DateTimePatternGenerator.getEmptyInstance();
36         for (String locale : cldrFactory.getAvailableLanguages()) {
37             if (defaultContentLocales.contains(locale)) {
38                 continue;
39             }
40             System.out.println(locale);
41             CLDRFile cldrFile = cldrFactory.make(locale, true);
42             for (String[] row : data) {
43                 String type = row[0];
44                 String length = row[1];
45                 String xpath = "//ldml/dates/calendars/calendar[@type=\"gregorian\"]/" +
46                     type + "Formats/" +
47                     type + "FormatLength[@type=\"" + length + "\"]/" +
48                     type + "Format[@type=\"standard\"]/pattern[@type=\"standard\"]";
49                 String value = cldrFile.getStringValue(xpath);
50                 String skeleton = dtpg.getSkeleton(value);
51                 skeleton = skeleton.replace("yyyy", "y");
52                 String key = type + "-" + length;
53                 Relation<String, String> skeletonToLocales = lengthToSkeletonToLocales.get(key);
54                 if (skeletonToLocales == null) {
55                     lengthToSkeletonToLocales.put(key, skeletonToLocales = Relation.of(new TreeMap<String, Set<String>>(), TreeSet.class));
56                 }
57                 skeletonToLocales.put(skeleton, locale);
58                 // System.out.println(key + "\t" + skeleton + "\t" + locale);
59             }
60         }
61         System.out.println();
62         for (Entry<String, Relation<String, String>> entry : lengthToSkeletonToLocales.entrySet()) {
63             for (Entry<String, Set<String>> entry2 : entry.getValue().keyValuesSet()) {
64                 System.out.println(entry.getKey() + "\t" + entry2.getKey() + "\t" + entry2.getValue());
65             }
66         }
67     }
68 }
69