1 /* |
1 /* |
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
21 * questions. |
21 * questions. |
22 */ |
22 */ |
23 |
23 |
24 import java.text.SimpleDateFormat; |
24 import java.text.SimpleDateFormat; |
25 import java.time.chrono.JapaneseDate; |
25 import java.time.chrono.JapaneseDate; |
|
26 import java.time.chrono.JapaneseEra; |
|
27 import java.time.format.TextStyle; |
26 import java.util.Calendar; |
28 import java.util.Calendar; |
27 import java.util.Date; |
29 import java.util.Date; |
28 import java.util.GregorianCalendar; |
30 import java.util.GregorianCalendar; |
29 import static java.util.GregorianCalendar.*; |
31 import static java.util.GregorianCalendar.*; |
30 import java.util.Locale; |
32 import java.util.Locale; |
138 expected = "Japanese " + NEW_ERA_NAME + " 1-02-11"; |
140 expected = "Japanese " + NEW_ERA_NAME + " 1-02-11"; |
139 if (!expected.equals(got)) { |
141 if (!expected.equals(got)) { |
140 System.err.printf("JapaneseDate: got=\"%s\", expected=\"%s\"%n", got, expected); |
142 System.err.printf("JapaneseDate: got=\"%s\", expected=\"%s\"%n", got, expected); |
141 errors++; |
143 errors++; |
142 } |
144 } |
|
145 JapaneseEra jera = jdate.getEra(); |
|
146 got = jera.getDisplayName(TextStyle.FULL, Locale.US); |
|
147 if (!NEW_ERA_NAME.equals(got)) { |
|
148 System.err.printf("JapaneseEra (FULL): got=\"%s\", expected=\"%s\"%n", got, NEW_ERA_NAME); |
|
149 errors++; |
|
150 } |
|
151 got = jera.getDisplayName(TextStyle.SHORT, Locale.US); |
|
152 if (!NEW_ERA_NAME.equals(got)) { |
|
153 System.err.printf("JapaneseEra (SHORT): got=\"%s\", expected=\"%s\"%n", got, NEW_ERA_NAME); |
|
154 errors++; |
|
155 } |
|
156 got = jera.getDisplayName(TextStyle.NARROW, Locale.US); |
|
157 if (!NEW_ERA_ABBR.equals(got)) { |
|
158 System.err.printf("JapaneseEra (NARROW): got=\"%s\", expected=\"%s\"%n", got, NEW_ERA_ABBR); |
|
159 errors++; |
|
160 } |
|
161 got = jera.getDisplayName(TextStyle.NARROW_STANDALONE, Locale.US); |
|
162 if (!NEW_ERA_ABBR.equals(got)) { |
|
163 System.err.printf("JapaneseEra (NARROW_STANDALONE): got=\"%s\", expected=\"%s\"%n", got, NEW_ERA_ABBR); |
|
164 errors++; |
|
165 } |
143 } |
166 } |
144 |
167 |
145 private static void testValidation(String eraName) { |
168 private static void testValidation(String eraName) { |
146 Calendar jcal = new Calendar.Builder() |
169 Calendar jcal = new Calendar.Builder() |
147 .setCalendarType("japanese") |
170 .setCalendarType("japanese") |