I have a code here that calculate a rate for payment. It works however certain value will result in numerous number of decimal points. I want the result to be converted into only 2 decimal point. How do I do this? below is the attached code:
double rateConv=(((new Double(4.4) * transaction.getAmount())/100)+(transaction.getAmount()+new Double(0.30)));
System.out.println(rateConv);
transaction.setCurrencyPsy(rateConv);
transaction.setUserId(getLoginUserProfile().getUserId());
transaction.setTransType(WalletConstant.TRANS_DEPOSIT);
transaction.setIsApproved(false);
transaction.setCreateDate(new Date());
transaction.setIsCiTrans(false);
transDAO.save(transaction,getLoginUserProfile(),getText("email.admin"));
if(transaction.getDepositType().equals(WalletConstant.DEPOSIT_WIREDTRANSFER)){
addActionMessage(getText("msg.success.tt"));
}else{
addActionMsg(getText("msg.success"));
}
transaction = new WalletTransaction();
} catch (Exception e) {
e.printStackTrace();
addActionErr(getText("Error in system.Please contact system's administrator."));
return ERROR;
}
execute();
return "paymount";
}
Thanks in advance