1 /*
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 import java.util.*;
25 import static java.util.GregorianCalendar.*;
26
27 public class NarrowNamesTest {
28 private static final Locale US = Locale.US;
29 private static final Locale JAJPJP = new Locale("ja", "JP", "JP");
30 private static final Locale THTH = new Locale("th", "TH");
31
32 private static final String RESET_INDEX = "RESET_INDEX";
33
34 private static int errors = 0;
35
36 // This test is locale data-dependent.
37 public static void main(String[] args) {
38 test(US, ERA, "B",
39 ERA, BC, YEAR, 1);
40 test(US, ERA, "A",
41 ERA, AD, YEAR, 2012);
42 test(US, DAY_OF_WEEK, "S",
43 YEAR, 2012, MONTH, DECEMBER, DAY_OF_MONTH, 23);
44 test(US, AM_PM, "a",
45 HOUR_OF_DAY, 10);
46 test(US, AM_PM, "p",
47 HOUR_OF_DAY, 23);
48 test(JAJPJP, DAY_OF_WEEK, "\u65e5",
49 YEAR, 24, MONTH, DECEMBER, DAY_OF_MONTH, 23);
50 test(THTH, MONTH, NARROW_STANDALONE, "\u0e18.\u0e04.",
51 YEAR, 2555, MONTH, DECEMBER, DAY_OF_MONTH, 5);
52 test(THTH, DAY_OF_WEEK, "\u0e1e",
53 YEAR, 2555, MONTH, DECEMBER, DAY_OF_MONTH, 5);
54
55 testMap(US, DAY_OF_WEEK, ALL_STYLES, // shouldn't include any narrow names
56 "", // 1-based indexing for DAY_OF_WEEK
57 "Sunday", // Sunday
59 "Tuesday", // Tuesday
60 "Wednesday", // Wednesday
61 "Thursday", // Thursday
62 "Friday", // Friday
63 "Saturday", // Saturday
64 RESET_INDEX,
65 "", // 1-based indexing for DAY_OF_WEEK
66 "Sun", // abb Sunday
67 "Mon", // abb Monday
68 "Tue", // abb Tuesday
69 "Wed", // abb Wednesday
70 "Thu", // abb Thursday
71 "Fri", // abb Friday
72 "Sat" // abb Saturday
73 );
74 testMap(US, DAY_OF_WEEK, NARROW_FORMAT); // expect null
75 testMap(US, AM_PM, ALL_STYLES,
76 "AM", "PM",
77 RESET_INDEX,
78 "a", "p");
79 testMap(JAJPJP, DAY_OF_WEEK, NARROW_STANDALONE); // expect null
80 testMap(JAJPJP, DAY_OF_WEEK, NARROW_FORMAT,
81 "", // 1-based indexing for DAY_OF_WEEK
82 "\u65e5",
83 "\u6708",
84 "\u706b",
85 "\u6c34",
86 "\u6728",
87 "\u91d1",
88 "\u571f");
89 testMap(THTH, MONTH, NARROW_FORMAT,
90 "\u0e21.\u0e04.",
91 "\u0e01.\u0e1e.",
92 "\u0e21\u0e35.\u0e04.",
93 "\u0e40\u0e21.\u0e22.",
94 "\u0e1e.\u0e04.",
95 "\u0e21\u0e34.\u0e22", // no last dot
96 "\u0e01.\u0e04.",
97 "\u0e2a.\u0e04.",
98 "\u0e01.\u0e22.",
99 "\u0e15.\u0e04.",
100 "\u0e1e.\u0e22.",
101 "\u0e18.\u0e04.");
102 testMap(THTH, MONTH, NARROW_STANDALONE,
103 "\u0e21.\u0e04.",
104 "\u0e01.\u0e1e.",
105 "\u0e21\u0e35.\u0e04.",
106 "\u0e40\u0e21.\u0e22.",
107 "\u0e1e.\u0e04.",
108 "\u0e21\u0e34.\u0e22.",
109 "\u0e01.\u0e04.",
110 "\u0e2a.\u0e04.",
111 "\u0e01.\u0e22.",
112 "\u0e15.\u0e04.",
113 "\u0e1e.\u0e22.",
114 "\u0e18.\u0e04.");
115
|
1 /*
2 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 import java.util.*;
25 import static java.util.GregorianCalendar.*;
26
27 public class NarrowNamesTest {
28 private static final Locale US = Locale.US;
29 private static final Locale JAJPJP = new Locale("ja", "JP", "JP");
30 private static final Locale THTH = new Locale("th", "TH");
31
32 private static final String RESET_INDEX = "RESET_INDEX";
33
34 private static int errors = 0;
35
36 private static String providers;
37
38 // This test is locale data-dependent.
39 public static void main(String[] args) {
40 providers = args[0];
41
42 test(US, ERA, "B",
43 ERA, BC, YEAR, 1);
44 test(US, ERA, "A",
45 ERA, AD, YEAR, 2012);
46 test(US, DAY_OF_WEEK, "S",
47 YEAR, 2012, MONTH, DECEMBER, DAY_OF_MONTH, 23);
48 test(US, AM_PM, "a",
49 HOUR_OF_DAY, 10);
50 test(US, AM_PM, "p",
51 HOUR_OF_DAY, 23);
52 test(JAJPJP, DAY_OF_WEEK, "\u65e5",
53 YEAR, 24, MONTH, DECEMBER, DAY_OF_MONTH, 23);
54 test(THTH, MONTH, NARROW_STANDALONE, "\u0e18.\u0e04.",
55 YEAR, 2555, MONTH, DECEMBER, DAY_OF_MONTH, 5);
56 test(THTH, DAY_OF_WEEK, "\u0e1e",
57 YEAR, 2555, MONTH, DECEMBER, DAY_OF_MONTH, 5);
58
59 testMap(US, DAY_OF_WEEK, ALL_STYLES, // shouldn't include any narrow names
60 "", // 1-based indexing for DAY_OF_WEEK
61 "Sunday", // Sunday
63 "Tuesday", // Tuesday
64 "Wednesday", // Wednesday
65 "Thursday", // Thursday
66 "Friday", // Friday
67 "Saturday", // Saturday
68 RESET_INDEX,
69 "", // 1-based indexing for DAY_OF_WEEK
70 "Sun", // abb Sunday
71 "Mon", // abb Monday
72 "Tue", // abb Tuesday
73 "Wed", // abb Wednesday
74 "Thu", // abb Thursday
75 "Fri", // abb Friday
76 "Sat" // abb Saturday
77 );
78 testMap(US, DAY_OF_WEEK, NARROW_FORMAT); // expect null
79 testMap(US, AM_PM, ALL_STYLES,
80 "AM", "PM",
81 RESET_INDEX,
82 "a", "p");
83 testMap(JAJPJP, DAY_OF_WEEK, NARROW_STANDALONE,
84 "", // 1-based indexing for DAY_OF_WEEK
85 "\u65e5",
86 "\u6708",
87 "\u706b",
88 "\u6c34",
89 "\u6728",
90 "\u91d1",
91 "\u571f");
92 testMap(JAJPJP, DAY_OF_WEEK, NARROW_FORMAT,
93 "", // 1-based indexing for DAY_OF_WEEK
94 "\u65e5",
95 "\u6708",
96 "\u706b",
97 "\u6c34",
98 "\u6728",
99 "\u91d1",
100 "\u571f");
101 testMap(THTH, MONTH, NARROW_FORMAT,
102 "\u0e21.\u0e04.",
103 "\u0e01.\u0e1e.",
104 "\u0e21\u0e35.\u0e04.",
105 "\u0e40\u0e21.\u0e22.",
106 "\u0e1e.\u0e04.",
107 (providers.startsWith("CLDR") ?
108 "\u0e21\u0e34.\u0e22." :
109 "\u0e21\u0e34.\u0e22"), // no last dot in JRE
110 "\u0e01.\u0e04.",
111 "\u0e2a.\u0e04.",
112 "\u0e01.\u0e22.",
113 "\u0e15.\u0e04.",
114 "\u0e1e.\u0e22.",
115 "\u0e18.\u0e04.");
116 testMap(THTH, MONTH, NARROW_STANDALONE,
117 "\u0e21.\u0e04.",
118 "\u0e01.\u0e1e.",
119 "\u0e21\u0e35.\u0e04.",
120 "\u0e40\u0e21.\u0e22.",
121 "\u0e1e.\u0e04.",
122 "\u0e21\u0e34.\u0e22.",
123 "\u0e01.\u0e04.",
124 "\u0e2a.\u0e04.",
125 "\u0e01.\u0e22.",
126 "\u0e15.\u0e04.",
127 "\u0e1e.\u0e22.",
128 "\u0e18.\u0e04.");
129
|