标签:设置 div amt ring span hal style blog ima
1、String to BigDecimal
1 String amtStr = "1234.56"; 2 BigDecimal amtBD = new BigDecimal(amtStr); 3 System.out.println("amtBD = " + amtBD); 4 System.out.println("amtBDV1 = " + amtBD.setScale(3,BigDecimal.ROUND_HALF_UP));//设置精度为3,四舍五入
2、Double to BigDecimal
Double doub = 1234.56; BigDecimal amtBDD = new BigDecimal(String.valueOf(doub)); System.out.println("amtBDD = " + amtBDD.setScale(1,BigDecimal.ROUND_HALF_UP)); //amtBDD = 1234.6
标签:设置 div amt ring span hal style blog ima
原文地址:http://www.cnblogs.com/xitangjuanjuan/p/6119468.html