< prev index next >

test/jdk/java/util/Locale/LocaleProviders.java

Print this page




 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 }


 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 }
< prev index next >