5.2. Define what a locale represents - Source Code

Code:

package c5.s2;

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

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

      long i = 14_092_011;

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

      // Switzerland
      Locale lc = new Locale("de", "CH");
      System.out.print(lc + " uses ");
      System.out.println(NumberFormat.getInstance(lc).format(i));
   }
}
					

output:

de_DE uses 14.092.011
de_CH uses 14'092'011
					

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