自己记录四舍五入,并且格式化

来源:互联网 发布:三菱plcfx3u编程软件 编辑:程序博客网 时间:2024/05/16 10:20
public static void main(String[] args) {    Double cc=99999999992.345;    //格式化为String    String str=String.format("%.2f",cc);    DecimalFormat decimalFormat = new DecimalFormat("#,##0.00");
 //如果需要数字,可以再d = Double.parseDouble(str)
System.out.println(decimalFormat.format(Double.parseDouble(str))); }
原创粉丝点击