博文

目前显示的是 七月, 2022的博文

Print out a number using the localized number, integer, currency, and percent format for each locale in Java

  private void testloc () { // Print out a number using the localized number, integer, currency, // and percent format for each locale Locale[] locales = NumberFormat. getAvailableLocales () ; double myNumber = - 1234.56 ; NumberFormat[] form = new NumberFormat[ 4 ] ; System. out .println( "FORMAT" ) ; int n = 0 ; for ( int i = 0 ; i < locales. length ; ++i) { if (locales[i].getCountry().length() == 0 ) { continue; // Skip language-only locales } n++ ; form[ 0 ] = NumberFormat. getInstance (locales[i]) ; form[ 1 ] = NumberFormat. getIntegerInstance (locales[i]) ; form[ 2 ] = NumberFormat. getCurrencyInstance (locales[i]) ; form[ 3 ] = NumberFormat. getPercentInstance (locales[i]) ; for ( int j = 0 ; j < 4 ; j++) { System. out .print(n + "." + (j + 1 ) + "." + locales[i].getDisplayName()) ; if (form[j] instanceof DecimalF...