BigDecimal.ZERO保留多位小数

1.把0设置成多位小数

        BigDecimal bigDecimal2 = BigDecimal.ZERO.setScale(4, BigDecimal.ROUND_HALF_UP);
        System.out.println(bigDecimal2.toString());//0.0000

        DecimalFormat df2 =new DecimalFormat("0.0000");
        String str2 =df2.format(Double.parseDouble(bigDecimal2.toString()));
        System.out.println(str2);//0.0000

 

posted @ 2020-05-10 15:44  梦浍烈风灵  阅读(3763)  评论(0编辑  收藏  举报