Java BigDecimal Format formatNumberDouble(Double amount, int scale)

Here you can find the source of formatNumberDouble(Double amount, int scale)

Description

format Number Double

License

Apache License

Declaration

public static double formatNumberDouble(Double amount, int scale) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.math.BigDecimal;

public class Main {
    public static double formatNumberDouble(Double amount, int scale) {
        if (null == amount)
            amount = 0.00;/*from   ww w . j  a va  2 s  . com*/
        BigDecimal b = new BigDecimal(amount).setScale(scale, BigDecimal.ROUND_HALF_UP);
        return b.doubleValue();
    }
}

Related

  1. formatNumber(double number)
  2. formatNumber(String format, BigDecimal number)
  3. formatNumberByMaxFrac(BigDecimal number, int val)
  4. formatNumberByMaxFracUseGrp(BigDecimal number, int val)
  5. formatNumberCroreFormat(final BigDecimal num)
  6. formatNumberStr(String numberStr, Integer scale)
  7. formatNumer(BigDecimal value, int decimalPlaces, Locale locale, boolean roundCommercial)
  8. formatoDecimal(String tipo, BigDecimal valor)
  9. formatPercent(BigDecimal percent)