方法一:格式化数字金额,并四舍五入
double amount = 10000.567;
//下面2行可不要
//BigDecimal bd = new BigDecimal(amount);
//amount = bd.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
DecimalFormat df = new DecimalFormat("#.00");
String result = df.format(amount);
System.out.println(result);
结果:10000.57
方法二:格式化出人民币符号+数字
double amount = 100.567;
NumberFormat currencyFormat = NumberFormat.getCurrencyInstance();
String result = currencyFormat.format(amount);
System.out.println(result);
结果:¥10,000.57
方式三:格式化带千分位的数字金额,并四舍五入
double amount = 10000.567;
//下面2行可不要
//BigDecimal bd = new BigDecimal(amount);
//amount = bd.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
DecimalFormat df = new DecimalFormat("#,###.00");
String result = df.format(amount);
System.out.println(result);
NumberFormat currencyFormat = NumberFormat.getCurrencyInstance();
结果:10,000.57