BigDecimal 保留2位,比较大小






java保留两位小数4种方法


BigDecimal bd = new BigDecimal(StringUtils.isBlank(td[11]) ? "0" : td[11].trim());
bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP);



addRisks.setPremium(new BigDecimal("0.00"));


比较大小

				BigDecimal amount = premium.multiply(new BigDecimal(20));//保额=保单的20倍
				amount = amount.setScale(2, BigDecimal.ROUND_HALF_UP);
				BigDecimal bigAmount = new BigDecimal(5000000);
				if (amount.compareTo(bigAmount) > 0) {
					amount = bigAmount;
				}
				addRisks.setAmount(amount);

你可能感兴趣的:(java)