1、String to BigDecimal
String amtStr = "1234.56";
BigDecimal amtBD = new BigDecimal(amtStr);
System.out.println("amtBD = " + amtBD);
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