Mon Apr 22, 2013 10:51 pm
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
public final class DecimalScaler {
private DecimalScaler() {
}
public static BigDecimal scaleBigDecimal(double val, int scale) {
BigDecimal value = new BigDecimal(Double.toString(val));
value = value.setScale(scale, RoundingMode.HALF_UP);
return value;
}
public static BigDecimal scaleBigDecimal(BigDecimal val, int scale) {
BigDecimal ret = val.setScale(scale, RoundingMode.HALF_UP);
return ret;
}
}
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.