javaLocale格式化日期和数字

阅读更多
public static void main(String[] args) {
		
Locale.setDefault(Locale.CHINA);
		
		//日期格式已设置为2017-8-25 9:37:55
		DateFormat df =  DateFormat.getDateTimeInstance();
		Date date = new Date();
		System.out.println(df.format(date));
		
		
		NumberFormat nf = NumberFormat.getInstance();
		long num = 12323344949L;
		System.out.println(nf.format(num));
		double dub = 2131.48236;
		System.out.println(nf.format(dub));
	}

输出:

2017-8-25 9:37:55
12,323,344,949
2,131.482

你可能感兴趣的:(javaLocale格式化日期和数字)