Here you can find the source of numberFormat(String pattern, BigDecimal number)
public static String numberFormat(String pattern, BigDecimal number)
//package com.java2s; //License from project: LGPL import java.math.BigDecimal; import java.text.DecimalFormat; public class Main { public static String numberFormat(String pattern, BigDecimal number) { String numberStr = null;/* w w w .j a v a2s .com*/ if (number == null) { return ""; } try { if (pattern == null || pattern.equals("")) { numberStr = new DecimalFormat("#0.00##").format(number.doubleValue()); } else { numberStr = new DecimalFormat(pattern).format(number.doubleValue()); } } catch (Exception e) { e.printStackTrace(); } return numberStr; } }