很烦人的一个警告,其实问题很无语,是常量roundingMode改了。
setScale(2, BigDecimal.ROUND_HALF_UP)改成setScale(2, RoundingMode.HALF_UP)就搞定了。
对照表如下:
java.math.BigDecimal.ROUND_CEILING Use RoundingMode.CEILING instead.
java.math.BigDecimal.ROUND_DOWN Use RoundingMode.DOWN instead.
java.math.BigDecimal.ROUND_FLOOR Use RoundingMode.FLOOR instead.
java.math.BigDecimal.ROUND_HALF_DOWN Use RoundingMode.HALF_DOWN instead.
java.math.BigDecimal.ROUND_HALF_EVEN Use RoundingMode.HALF_EVEN instead.
java.math.BigDecimal.ROUND_HALF_UP Use RoundingMode.HALF_UP instead.
java.math.BigDecimal.ROUND_UNNECESSARY Use RoundingMode.UNNECESSARY instead.
java.math.BigDecimal.ROUND_UP Use RoundingMode.UP instead.
网友评论