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