Java BigDecimal Format formatMoney(BigDecimal money, int scale, double divisor)

Here you can find the source of formatMoney(BigDecimal money, int scale, double divisor)

Description

format Money

License

Open Source License

Declaration

private static String formatMoney(BigDecimal money, int scale, double divisor) 

Method Source Code


//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();
    }
}

Related

  1. formatFAAssertRatioWithoutPercent(BigDecimal value)
  2. formatFileSize(double size)
  3. formatFloat0(String value, int n)
  4. formatForPercentage(BigDecimal value)
  5. formatManey(BigDecimal date)
  6. formatMoney(long value)
  7. formatNoDecimalPoint(double amt)
  8. formatNumber(double number)
  9. formatNumber(String format, BigDecimal number)