Here you can find the source of formatMoney(BigDecimal money, int scale, double divisor)
private static String formatMoney(BigDecimal money, int scale, double divisor)
//package com.java2s; //License from project: Open Source License import java.math.BigDecimal; import java.math.RoundingMode; public class Main { private static String formatMoney(BigDecimal money, int scale, double divisor) { if (divisor == 0) { return "0.00"; }/*from w ww. j a v a 2 s .c o m*/ if (scale < 0) { return "0.00"; } BigDecimal divisorBD = new BigDecimal(divisor); return money.divide(divisorBD, scale, RoundingMode.HALF_UP).toString(); } }