Here you can find the source of calculateProfit(BigDecimal totalAmt, Integer duration, BigDecimal rate)
public static BigDecimal calculateProfit(BigDecimal totalAmt, Integer duration, BigDecimal rate)
//package com.java2s; //License from project: Apache License import java.math.BigDecimal; import java.math.RoundingMode; import java.util.Calendar; public class Main { public static BigDecimal calculateProfit(BigDecimal totalAmt, Integer duration, BigDecimal rate) { Calendar cal = Calendar.getInstance(); int maxDayNum = cal.getActualMaximum(Calendar.DAY_OF_YEAR); return totalAmt.multiply(new BigDecimal(duration)).multiply(rate).divide(new BigDecimal(maxDayNum * 100), 2, RoundingMode.CEILING); }//from w w w.j av a 2 s . c om }