获取货币格式对象
public static NumberFormat getCurrencyInstance(Locale inLocale)
1 import java.text.NumberFormat; 2 import java.util.Locale; 3 import java.util.Scanner; 4 5 public class FormatNumber { 6 public static void main(String args[]) { 7 Scanner scanner = new Scanner(System.in); 8 System.out.println("请输入数字:"); 9 double number = scanner.nextDouble(); 10 NumberFormat format = NumberFormat.getCurrencyInstance(Locale.CHINA); 11 System.out.println("China:"+format.format(number)); 12 13 format = NumberFormat.getCurrencyInstance(Locale.ENGLISH); 14 System.out.println("ENGLISH:"+format.format(number)); 15 16 format = NumberFormat.getCurrencyInstance(Locale.US); 17 System.out.println("US:"+format.format(number)); 18 } 19 20 21 }