1 /*
2 * Copyright (c) 2012, 2016, 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 */
220 sdf.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));
221 String result = sdf.format(sampleDate);
222 System.out.println(result);
223 if (LocaleProviderAdapter.getAdapterPreference()
224 .contains(LocaleProviderAdapter.Type.JRE)) {
225 if (!jreResult.equals(result)) {
226 throw new RuntimeException("Format failed. result: \"" +
227 result + "\", expected: \"" + jreResult);
228 }
229 } else {
230 // Windows display names. Subject to change if Windows changes its format.
231 if (!hostResult.equals(result)) {
232 throw new RuntimeException("Format failed. result: \"" +
233 result + "\", expected: \"" + hostResult);
234 }
235 }
236 }
237 }
238
239 static void bug8027289Test(String expectedCodePoint) {
240 char[] expectedSymbol = Character.toChars(Integer.valueOf(expectedCodePoint, 16));
241 NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.CHINA);
242 char formatted = nf.format(7000).charAt(0);
243 System.out.println("returned: " + formatted + ", expected: " + expectedSymbol[0]);
244 if (formatted != expectedSymbol[0]) {
245 throw new RuntimeException("Unexpected Chinese currency symbol. returned: " + formatted + ", expected: " + expectedSymbol[0]);
246 }
247 }
248 }
|
1 /*
2 * Copyright (c) 2012, 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 */
220 sdf.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));
221 String result = sdf.format(sampleDate);
222 System.out.println(result);
223 if (LocaleProviderAdapter.getAdapterPreference()
224 .contains(LocaleProviderAdapter.Type.JRE)) {
225 if (!jreResult.equals(result)) {
226 throw new RuntimeException("Format failed. result: \"" +
227 result + "\", expected: \"" + jreResult);
228 }
229 } else {
230 // Windows display names. Subject to change if Windows changes its format.
231 if (!hostResult.equals(result)) {
232 throw new RuntimeException("Format failed. result: \"" +
233 result + "\", expected: \"" + hostResult);
234 }
235 }
236 }
237 }
238
239 static void bug8027289Test(String expectedCodePoint) {
240 if (System.getProperty("os.name").startsWith("Windows")) {
241 char[] expectedSymbol = Character.toChars(Integer.valueOf(expectedCodePoint, 16));
242 NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.CHINA);
243 char formatted = nf.format(7000).charAt(0);
244 System.out.println("returned: " + formatted + ", expected: " + expectedSymbol[0]);
245 if (formatted != expectedSymbol[0]) {
246 throw new RuntimeException(
247 "Unexpected Chinese currency symbol. returned: "
248 + formatted + ", expected: " + expectedSymbol[0]);
249 }
250 }
251 }
252 }
|