BigDecimal的数值计算

计算BigDecimal类型的数值:
BigDecimal recharge = new BigDecimal(0);// 充值的总金额
List<UserAccount> userAccountList = UserAccountService.getLookupUserAccount("0");

		for (UserAccount account : userAccountList) {
			recharge = (account.getMoney()).add(recharge);
		}
		BigDecimal expend = new BigDecimal(0);// 消费的总金额
		List<UserAccount> accounts = UserAccountService.getLookupUserAccount("1");

		for (UserAccount account : accounts) {
			expend = (account.getMoney()).add(expend);
		} 
		BigDecimal balance =recharge.subtract(expend);// 账户余额=recharge - expend 

你可能感兴趣的:(BigDecimal)