23 |
23 |
24 import java.text.SimpleDateFormat; |
24 import java.text.SimpleDateFormat; |
25 import java.time.chrono.JapaneseChronology; |
25 import java.time.chrono.JapaneseChronology; |
26 import java.time.chrono.JapaneseDate; |
26 import java.time.chrono.JapaneseDate; |
27 import java.time.chrono.JapaneseEra; |
27 import java.time.chrono.JapaneseEra; |
28 import java.time.format.DateTimeFormatterBuilder; |
28 import java.time.format.DateTimeFormatter; |
29 import java.time.format.TextStyle; |
29 import java.time.format.TextStyle; |
30 import java.util.Calendar; |
30 import java.util.Calendar; |
31 import java.util.Date; |
31 import java.util.Date; |
32 import java.util.GregorianCalendar; |
32 import java.util.GregorianCalendar; |
33 import static java.util.GregorianCalendar.*; |
33 import static java.util.GregorianCalendar.*; |
164 if (!NEW_ERA_ABBR.equals(got)) { |
164 if (!NEW_ERA_ABBR.equals(got)) { |
165 System.err.printf("JapaneseEra (NARROW_STANDALONE): got=\"%s\", expected=\"%s\"%n", got, NEW_ERA_ABBR); |
165 System.err.printf("JapaneseEra (NARROW_STANDALONE): got=\"%s\", expected=\"%s\"%n", got, NEW_ERA_ABBR); |
166 errors++; |
166 errors++; |
167 } |
167 } |
168 |
168 |
169 // test long/abbreviated names with java.time.format |
169 // test full/short/narrow names with java.time.format |
170 got = new DateTimeFormatterBuilder() |
170 got = DateTimeFormatter |
171 .appendPattern("GGGG") |
171 .ofPattern("GGGG G GGGGG") |
172 .appendLiteral(" ") |
172 .withLocale(Locale.US) |
173 .appendPattern("G") |
|
174 .toFormatter(Locale.US) |
|
175 .withChronology(JapaneseChronology.INSTANCE) |
173 .withChronology(JapaneseChronology.INSTANCE) |
176 .format(jdate); |
174 .format(jdate); |
177 expected = NEW_ERA_NAME + " " + NEW_ERA_ABBR; |
175 expected = NEW_ERA_NAME + " " + NEW_ERA_NAME + " " + NEW_ERA_ABBR; |
178 if (!expected.equals(got)) { |
176 if (!expected.equals(got)) { |
179 System.err.printf("java.time formatter long/abbr names: got=\"%s\", expected=\"%s\"%n", got, expected); |
177 System.err.printf("java.time formatter full/short/narrow names: got=\"%s\", expected=\"%s\"%n", got, expected); |
180 errors++; |
178 errors++; |
181 } |
179 } |
182 } |
180 } |
183 |
181 |
184 private static void testValidation(String eraName) { |
182 private static void testValidation(String eraName) { |