author | phh |
Sat, 30 Nov 2019 14:33:05 -0800 | |
changeset 59330 | 5b96c12f909d |
parent 52234 | 5bd3a6017943 |
permissions | -rw-r--r-- |
25966
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
1 |
/* |
50478 | 2 |
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. |
25966
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
4 |
* |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
8 |
* |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
13 |
* accompanied this code). |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
14 |
* |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
18 |
* |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
21 |
* questions. |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
22 |
*/ |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
23 |
|
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
24 |
import java.text.SimpleDateFormat; |
43338
f9c4f82a8265
8173423: Wrong display name for supplemental Japanese era
naoto
parents:
42696
diff
changeset
|
25 |
import java.time.chrono.JapaneseChronology; |
25966
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
26 |
import java.time.chrono.JapaneseDate; |
42696
a0df1f76b88e
8054214: JapaneseEra.getDisplayName doesn't return names if it's an additional era
okutsu
parents:
25966
diff
changeset
|
27 |
import java.time.chrono.JapaneseEra; |
47030
d548b7a9ba3e
8180469: Wrong short form text for supplemental Japanese era
naoto
parents:
43338
diff
changeset
|
28 |
import java.time.format.DateTimeFormatter; |
42696
a0df1f76b88e
8054214: JapaneseEra.getDisplayName doesn't return names if it's an additional era
okutsu
parents:
25966
diff
changeset
|
29 |
import java.time.format.TextStyle; |
25966
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
30 |
import java.util.Calendar; |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
31 |
import java.util.Date; |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
32 |
import java.util.GregorianCalendar; |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
33 |
import static java.util.GregorianCalendar.*; |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
34 |
import java.util.Locale; |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
35 |
|
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
36 |
/* |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
37 |
* Usage: |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
38 |
* java -Djdk.calendar.japanese.supplemental.era=... SupplementalJapaneseEraTest <flag> |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
39 |
* -t executes tests with a valid property value |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
40 |
* -b <eraname> |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
41 |
* executes tests with an invalid property value |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
42 |
*/ |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
43 |
|
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
44 |
public class SupplementalJapaneseEraTest { |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
45 |
private static final Locale WAREKI_LOCALE = Locale.forLanguageTag("ja-JP-u-ca-japanese"); |
50478 | 46 |
private static final String SUP_ERA_NAME = "SupEra"; |
47 |
private static final String SUP_ERA_ABBR = "S.E."; |
|
25966
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
48 |
private static int errors = 0; |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
49 |
|
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
50 |
public static void main(String[] args) { |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
51 |
// args[0] is a flag. |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
52 |
switch (args[0]) { |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
53 |
case "-t": |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
54 |
// test with a valid property value |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
55 |
testProperty(); |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
56 |
break; |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
57 |
|
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
58 |
case "-b": |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
59 |
// test with an invalid property value |
52234
5bd3a6017943
8210407: Refactor java.util.Calendar:i18n shell tests to plain java tests
mli
parents:
50478
diff
changeset
|
60 |
// args[1] is the current era name. |
25966
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
61 |
testValidation(args[1].replace("\r", "")); // remove any CR for Cygwin |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
62 |
break; |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
63 |
} |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
64 |
if (errors != 0) { |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
65 |
throw new RuntimeException("test failed"); |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
66 |
} |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
67 |
} |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
68 |
|
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
69 |
private static void testProperty() { |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
70 |
Calendar jcal = new Calendar.Builder() |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
71 |
.setCalendarType("japanese") |
50478 | 72 |
.setFields(ERA, 6, YEAR, 1, DAY_OF_YEAR, 1) |
25966
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
73 |
.build(); |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
74 |
Date firstDayOfEra = jcal.getTime(); |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
75 |
jcal.set(ERA, jcal.get(ERA) - 1); // previous era |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
76 |
jcal.set(YEAR, 1); |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
77 |
jcal.set(DAY_OF_YEAR, 1); |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
78 |
Calendar cal = new GregorianCalendar(); |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
79 |
cal.setTimeInMillis(jcal.getTimeInMillis()); |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
80 |
cal.add(YEAR, 199); |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
81 |
int year = cal.get(YEAR); |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
82 |
|
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
83 |
SimpleDateFormat sdf; |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
84 |
String expected, got; |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
85 |
|
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
86 |
// test long era name |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
87 |
sdf = new SimpleDateFormat("GGGG y-MM-dd", WAREKI_LOCALE); |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
88 |
got = sdf.format(firstDayOfEra); |
50478 | 89 |
expected = SUP_ERA_NAME + " 1-02-11"; |
25966
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
90 |
if (!expected.equals(got)) { |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
91 |
System.err.printf("GGGG y-MM-dd: got=\"%s\", expected=\"%s\"%n", got, expected); |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
92 |
errors++; |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
93 |
} |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
94 |
|
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
95 |
// test era abbreviation |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
96 |
sdf = new SimpleDateFormat("G y-MM-dd", WAREKI_LOCALE); |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
97 |
got = sdf.format(firstDayOfEra); |
50478 | 98 |
expected = SUP_ERA_ABBR + " 1-02-11"; |
25966
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
99 |
if (!expected.equals(got)) { |
43338
f9c4f82a8265
8173423: Wrong display name for supplemental Japanese era
naoto
parents:
42696
diff
changeset
|
100 |
System.err.printf("G y-MM-dd: got=\"%s\", expected=\"%s\"%n", got, expected); |
25966
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
101 |
errors++; |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
102 |
} |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
103 |
|
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
104 |
// confirm the gregorian year |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
105 |
sdf = new SimpleDateFormat("y", Locale.US); |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
106 |
int y = Integer.parseInt(sdf.format(firstDayOfEra)); |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
107 |
if (y != year) { |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
108 |
System.err.printf("Gregorian year: got=%d, expected=%d%n", y, year); |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
109 |
errors++; |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
110 |
} |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
111 |
|
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
112 |
// test java.time.chrono.JapaneseEra |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
113 |
JapaneseDate jdate = JapaneseDate.of(year, 2, 11); |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
114 |
got = jdate.toString(); |
50478 | 115 |
expected = "Japanese " + SUP_ERA_NAME + " 1-02-11"; |
25966
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
116 |
if (!expected.equals(got)) { |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
117 |
System.err.printf("JapaneseDate: got=\"%s\", expected=\"%s\"%n", got, expected); |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
118 |
errors++; |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
119 |
} |
42696
a0df1f76b88e
8054214: JapaneseEra.getDisplayName doesn't return names if it's an additional era
okutsu
parents:
25966
diff
changeset
|
120 |
JapaneseEra jera = jdate.getEra(); |
a0df1f76b88e
8054214: JapaneseEra.getDisplayName doesn't return names if it's an additional era
okutsu
parents:
25966
diff
changeset
|
121 |
got = jera.getDisplayName(TextStyle.FULL, Locale.US); |
50478 | 122 |
if (!SUP_ERA_NAME.equals(got)) { |
123 |
System.err.printf("JapaneseEra (FULL): got=\"%s\", expected=\"%s\"%n", got, SUP_ERA_NAME); |
|
42696
a0df1f76b88e
8054214: JapaneseEra.getDisplayName doesn't return names if it's an additional era
okutsu
parents:
25966
diff
changeset
|
124 |
errors++; |
a0df1f76b88e
8054214: JapaneseEra.getDisplayName doesn't return names if it's an additional era
okutsu
parents:
25966
diff
changeset
|
125 |
} |
a0df1f76b88e
8054214: JapaneseEra.getDisplayName doesn't return names if it's an additional era
okutsu
parents:
25966
diff
changeset
|
126 |
got = jera.getDisplayName(TextStyle.SHORT, Locale.US); |
50478 | 127 |
if (!SUP_ERA_NAME.equals(got)) { |
128 |
System.err.printf("JapaneseEra (SHORT): got=\"%s\", expected=\"%s\"%n", got, SUP_ERA_NAME); |
|
42696
a0df1f76b88e
8054214: JapaneseEra.getDisplayName doesn't return names if it's an additional era
okutsu
parents:
25966
diff
changeset
|
129 |
errors++; |
a0df1f76b88e
8054214: JapaneseEra.getDisplayName doesn't return names if it's an additional era
okutsu
parents:
25966
diff
changeset
|
130 |
} |
a0df1f76b88e
8054214: JapaneseEra.getDisplayName doesn't return names if it's an additional era
okutsu
parents:
25966
diff
changeset
|
131 |
got = jera.getDisplayName(TextStyle.NARROW, Locale.US); |
50478 | 132 |
if (!SUP_ERA_ABBR.equals(got)) { |
133 |
System.err.printf("JapaneseEra (NARROW): got=\"%s\", expected=\"%s\"%n", got, SUP_ERA_ABBR); |
|
42696
a0df1f76b88e
8054214: JapaneseEra.getDisplayName doesn't return names if it's an additional era
okutsu
parents:
25966
diff
changeset
|
134 |
errors++; |
a0df1f76b88e
8054214: JapaneseEra.getDisplayName doesn't return names if it's an additional era
okutsu
parents:
25966
diff
changeset
|
135 |
} |
a0df1f76b88e
8054214: JapaneseEra.getDisplayName doesn't return names if it's an additional era
okutsu
parents:
25966
diff
changeset
|
136 |
got = jera.getDisplayName(TextStyle.NARROW_STANDALONE, Locale.US); |
50478 | 137 |
if (!SUP_ERA_ABBR.equals(got)) { |
138 |
System.err.printf("JapaneseEra (NARROW_STANDALONE): got=\"%s\", expected=\"%s\"%n", got, SUP_ERA_ABBR); |
|
42696
a0df1f76b88e
8054214: JapaneseEra.getDisplayName doesn't return names if it's an additional era
okutsu
parents:
25966
diff
changeset
|
139 |
errors++; |
a0df1f76b88e
8054214: JapaneseEra.getDisplayName doesn't return names if it's an additional era
okutsu
parents:
25966
diff
changeset
|
140 |
} |
43338
f9c4f82a8265
8173423: Wrong display name for supplemental Japanese era
naoto
parents:
42696
diff
changeset
|
141 |
|
47030
d548b7a9ba3e
8180469: Wrong short form text for supplemental Japanese era
naoto
parents:
43338
diff
changeset
|
142 |
// test full/short/narrow names with java.time.format |
d548b7a9ba3e
8180469: Wrong short form text for supplemental Japanese era
naoto
parents:
43338
diff
changeset
|
143 |
got = DateTimeFormatter |
d548b7a9ba3e
8180469: Wrong short form text for supplemental Japanese era
naoto
parents:
43338
diff
changeset
|
144 |
.ofPattern("GGGG G GGGGG") |
d548b7a9ba3e
8180469: Wrong short form text for supplemental Japanese era
naoto
parents:
43338
diff
changeset
|
145 |
.withLocale(Locale.US) |
43338
f9c4f82a8265
8173423: Wrong display name for supplemental Japanese era
naoto
parents:
42696
diff
changeset
|
146 |
.withChronology(JapaneseChronology.INSTANCE) |
f9c4f82a8265
8173423: Wrong display name for supplemental Japanese era
naoto
parents:
42696
diff
changeset
|
147 |
.format(jdate); |
50478 | 148 |
expected = SUP_ERA_NAME + " " + SUP_ERA_NAME + " " + SUP_ERA_ABBR; |
43338
f9c4f82a8265
8173423: Wrong display name for supplemental Japanese era
naoto
parents:
42696
diff
changeset
|
149 |
if (!expected.equals(got)) { |
47030
d548b7a9ba3e
8180469: Wrong short form text for supplemental Japanese era
naoto
parents:
43338
diff
changeset
|
150 |
System.err.printf("java.time formatter full/short/narrow names: got=\"%s\", expected=\"%s\"%n", got, expected); |
43338
f9c4f82a8265
8173423: Wrong display name for supplemental Japanese era
naoto
parents:
42696
diff
changeset
|
151 |
errors++; |
f9c4f82a8265
8173423: Wrong display name for supplemental Japanese era
naoto
parents:
42696
diff
changeset
|
152 |
} |
25966
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
153 |
} |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
154 |
|
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
155 |
private static void testValidation(String eraName) { |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
156 |
Calendar jcal = new Calendar.Builder() |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
157 |
.setCalendarType("japanese") |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
158 |
.setFields(YEAR, 1, DAY_OF_YEAR, 1) |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
159 |
.build(); |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
160 |
if (!jcal.getDisplayName(ERA, LONG, Locale.US).equals(eraName)) { |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
161 |
errors++; |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
162 |
String prop = System.getProperty("jdk.calendar.japanese.supplemental.era"); |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
163 |
System.err.println("Era changed with invalid property: " + prop); |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
164 |
} |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
165 |
} |
71ee1f15845e
8048123: Replace calendars.properties with another mechanism to specify a new Japanese calendar era
okutsu
parents:
diff
changeset
|
166 |
} |