package Demo;
import java.text.NumberFormat;
import java.util.Locale;
import java.util.Scanner;
public class FormatNumber {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.print("请输入一个数字:");
double number = s.nextDouble();
System.out.println("Locale类的常量作为构造参数获得不同的货币格式:");
NumberFormat format = NumberFormat.getCurrencyInstance(Locale.CHINA);//创建格式化对象
System.out.println("Locale.CHINA:"+format.format(number));//输出格式化货币
format = NumberFormat.getCurrencyInstance(Locale.US);
System.out.println("Locale.UA:"+format.format(number));
format = NumberFormat.getCurrencyInstance(Locale.JAPAN);
System.out.println("Locale.JAPAN"+format.format(number));
}
}