1 /*
2 * Copyright (c) 2013, 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 */
28 * on calling localizedDateTime().print() with JapaneseChrono
29 * @compile -XDignore.symbol.file Bug8007038.java
30 * @run main Bug8007038
31 */
32
33 import java.util.*;
34 import static java.util.Calendar.*;
35 import sun.util.locale.provider.CalendarDataUtility;
36
37 public class Bug8007038 {
38 private final static String[] calTypes = {
39 "gregory",
40 "buddhist",
41 "japanese",
42 "roc",
43 "islamic",
44 };
45 private final static int[][] eraMinMax = {
46 {GregorianCalendar.BC, GregorianCalendar.AD},
47 {0, 1},
48 {0, 4},
49 {0, 1},
50 {0, 1},
51 {0, 1},
52 };
53 private final static Locale[] testLocs = {
54 Locale.ROOT,
55 Locale.forLanguageTag("ja-JP-u-ca-japanese"),
56 Locale.forLanguageTag("th-TH"),
57 Locale.forLanguageTag("th-TH-u-ca-buddhist"),
58 Locale.forLanguageTag("zh-TW-u-ca-roc"),
59 Locale.forLanguageTag("ar-EG-u-ca-islamic"),
60 Locale.forLanguageTag("xx-YY-u-ca-bogus"),
61 };
62
63 public static void main(String[] args) {
64 for (int calIdx = 0; calIdx < calTypes.length; calIdx++) {
65 for (int locIdx = 0; locIdx < testLocs.length; locIdx++) {
66 // era
67 for (int fieldIdx = eraMinMax[calIdx][0]; fieldIdx <= eraMinMax[calIdx][1]; fieldIdx++) {
68 checkValueRange(calTypes[calIdx], ERA, fieldIdx, LONG, testLocs[locIdx], true);
|
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 */
28 * on calling localizedDateTime().print() with JapaneseChrono
29 * @compile -XDignore.symbol.file Bug8007038.java
30 * @run main Bug8007038
31 */
32
33 import java.util.*;
34 import static java.util.Calendar.*;
35 import sun.util.locale.provider.CalendarDataUtility;
36
37 public class Bug8007038 {
38 private final static String[] calTypes = {
39 "gregory",
40 "buddhist",
41 "japanese",
42 "roc",
43 "islamic",
44 };
45 private final static int[][] eraMinMax = {
46 {GregorianCalendar.BC, GregorianCalendar.AD},
47 {0, 1},
48 {0, 5},
49 {0, 1},
50 {0, 1},
51 {0, 1},
52 };
53 private final static Locale[] testLocs = {
54 Locale.ROOT,
55 Locale.forLanguageTag("ja-JP-u-ca-japanese"),
56 Locale.forLanguageTag("th-TH"),
57 Locale.forLanguageTag("th-TH-u-ca-buddhist"),
58 Locale.forLanguageTag("zh-TW-u-ca-roc"),
59 Locale.forLanguageTag("ar-EG-u-ca-islamic"),
60 Locale.forLanguageTag("xx-YY-u-ca-bogus"),
61 };
62
63 public static void main(String[] args) {
64 for (int calIdx = 0; calIdx < calTypes.length; calIdx++) {
65 for (int locIdx = 0; locIdx < testLocs.length; locIdx++) {
66 // era
67 for (int fieldIdx = eraMinMax[calIdx][0]; fieldIdx <= eraMinMax[calIdx][1]; fieldIdx++) {
68 checkValueRange(calTypes[calIdx], ERA, fieldIdx, LONG, testLocs[locIdx], true);
|