//use Number Format 格式化数据
import java.text.*;
import java.util.*;
public class IntegerSample {
public static void main(String args[]) {
int amount = 54321;
NumberFormat myformat = NumberFormat.getInstance();//system format
System.out.println(myformat.format(amount));
NumberFormat usformat = NumberFormat.getIntegerInstance(Locale.US);//use format
System.out.println(usformat.format(amount));
NumberFormat germanformat = NumberFormat.getInstance(Locale.CHINA);//china format
System.out.println(germanformat.format(amount));
NumberFormat jaformat = NumberFormat.getInstance(Locale.JAPAN);//japan format
System.out.println(jaformat.format(amount));
}
}
//---------------------------------//
运行结果:
F:\2004-04-12>java IntegerSample
54,321
54,321
54,321
54,321