Here you can find the source of getDecimalFormat(int i, String numStr)
public static String getDecimalFormat(int i, String numStr)
//package com.java2s; import java.math.BigDecimal; public class Main { public static String getDecimalFormat(int i, String numStr) { try {// w ww . j a v a2 s .c o m if (numStr != null && !"".equals(numStr)) { BigDecimal bd = new BigDecimal(numStr); bd = bd.setScale(i, BigDecimal.ROUND_HALF_UP); return bd.toString(); } else { return ""; } } catch (Exception e) { return ""; } } }