Appendix 5. Localization

5.1. Describe the advantages of localizing an application - Source Code

Code:

package c5.s1;

import java.text.NumberFormat;
import java.util.Locale;

/**
 * @author Mikalai Zaikin
 */
public class LocaleDemo {
    public static void main(String... args) {

      int i = 14_092_011;

      Locale l1 = Locale.FRANCE;
      System.out.print(l1 + " uses ");
      System.out.println(NumberFormat.getInstance(l1).format(i));

      Locale l2 = new Locale("de", "DE");
      System.out.print(l2 + " uses ");
      System.out.println(NumberFormat.getInstance(l2).format(i));

      Locale l3 = new Locale("en", "US");
      System.out.print(l3 + " uses ");
      System.out.println(NumberFormat.getInstance(l3).format(i));
   }
}
					

output:

fr_FR uses 14 092 011
de_DE uses 14.092.011
en_US uses 14,092,011
					

Professional hosting         Free 'Oracle Certified Expert Web Services Developer 6' Guide     Free SCDJWS 5.0 Guide