Java BigDecimal Format formatNumberStr(String numberStr, Integer scale)

Here you can find the source of formatNumberStr(String numberStr, Integer scale)

Description

format Number Str

License

Open Source License

Declaration

public static BigDecimal formatNumberStr(String numberStr, Integer scale) 

Method Source Code


//package com.java2s;

import java.math.BigDecimal;

public class Main {

    public static BigDecimal formatNumberStr(String numberStr, Integer scale) {
        BigDecimal bigVal = null;
        try {/*from ww w .ja v  a  2 s.c  om*/
            bigVal = new BigDecimal(numberStr);
            if (null == scale)
                return bigVal;
            return bigVal.setScale(scale, BigDecimal.ROUND_HALF_UP);
        } catch (Exception e) {
            return null;
        }
    }
}

Related

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