1 /*
2 * Copyright (c) 2013, 2018, 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 */
126 { ISO8601, Locale.JAPANESE, "ISO" }, // No data in CLDR; Use Id.
127 { JAPANESE, Locale.JAPANESE, "\u548c\u66a6" },
128 { BUDDHIST, Locale.JAPANESE, "\u4ecf\u66a6" },
129
130 { ISO8601, thTH, "ISO" }, // No data in CLDR; Use Id.
131 { JAPANESE, thTH, "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e0d\u0e35\u0e48\u0e1b\u0e38\u0e48\u0e19" },
132 { BUDDHIST, thTH, "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e1e\u0e38\u0e17\u0e18" },
133
134 { HIJRAH, ARABIC, "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 "
135 + "\u0627\u0644\u0625\u0633\u0644\u0627\u0645\u064a "
136 + "(\u0623\u0645 \u0627\u0644\u0642\u0631\u0649)" },
137 };
138 }
139
140 @DataProvider(name="lenient_eraYear")
141 Object[][] lenientEraYear() {
142 return new Object[][] {
143 // Chronology, lenient era/year, strict era/year
144 { JAPANESE, "Meiji 123", "Heisei 2" },
145 { JAPANESE, "Showa 65", "Heisei 2" },
146 { JAPANESE, "Heisei 32", "NewEra 2" }, // NewEra
147 };
148 }
149
150 @Test(dataProvider="format_data")
151 public void test_formatLocalizedDate(Chronology chrono, Locale formatLocale, Locale numberingLocale,
152 ChronoLocalDate date, String expected) {
153 DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL)
154 .withChronology(chrono).withLocale(formatLocale)
155 .withDecimalStyle(DecimalStyle.of(numberingLocale));
156 String text = dtf.format(date);
157 assertEquals(text, expected);
158 }
159
160 @Test(dataProvider="format_data")
161 public void test_parseLocalizedText(Chronology chrono, Locale formatLocale, Locale numberingLocale,
162 ChronoLocalDate expected, String text) {
163 DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL)
164 .withChronology(chrono).withLocale(formatLocale)
165 .withDecimalStyle(DecimalStyle.of(numberingLocale));
166 TemporalAccessor temporal = dtf.parse(text);
|
1 /*
2 * Copyright (c) 2013, 2019, 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 */
126 { ISO8601, Locale.JAPANESE, "ISO" }, // No data in CLDR; Use Id.
127 { JAPANESE, Locale.JAPANESE, "\u548c\u66a6" },
128 { BUDDHIST, Locale.JAPANESE, "\u4ecf\u66a6" },
129
130 { ISO8601, thTH, "ISO" }, // No data in CLDR; Use Id.
131 { JAPANESE, thTH, "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e0d\u0e35\u0e48\u0e1b\u0e38\u0e48\u0e19" },
132 { BUDDHIST, thTH, "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e1e\u0e38\u0e17\u0e18" },
133
134 { HIJRAH, ARABIC, "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 "
135 + "\u0627\u0644\u0625\u0633\u0644\u0627\u0645\u064a "
136 + "(\u0623\u0645 \u0627\u0644\u0642\u0631\u0649)" },
137 };
138 }
139
140 @DataProvider(name="lenient_eraYear")
141 Object[][] lenientEraYear() {
142 return new Object[][] {
143 // Chronology, lenient era/year, strict era/year
144 { JAPANESE, "Meiji 123", "Heisei 2" },
145 { JAPANESE, "Showa 65", "Heisei 2" },
146 { JAPANESE, "Heisei 32", "Reiwa 2" },
147 };
148 }
149
150 @Test(dataProvider="format_data")
151 public void test_formatLocalizedDate(Chronology chrono, Locale formatLocale, Locale numberingLocale,
152 ChronoLocalDate date, String expected) {
153 DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL)
154 .withChronology(chrono).withLocale(formatLocale)
155 .withDecimalStyle(DecimalStyle.of(numberingLocale));
156 String text = dtf.format(date);
157 assertEquals(text, expected);
158 }
159
160 @Test(dataProvider="format_data")
161 public void test_parseLocalizedText(Chronology chrono, Locale formatLocale, Locale numberingLocale,
162 ChronoLocalDate expected, String text) {
163 DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL)
164 .withChronology(chrono).withLocale(formatLocale)
165 .withDecimalStyle(DecimalStyle.of(numberingLocale));
166 TemporalAccessor temporal = dtf.parse(text);
|