Here you can find the source of formatNumberStr(String numberStr, Integer scale)
public static BigDecimal formatNumberStr(String numberStr, Integer scale)
//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; } } }