Here you can find the source of format(BigDecimal num)
public static String format(BigDecimal num)
//package com.java2s; //License from project: Open Source License import java.math.BigDecimal; import java.text.NumberFormat; public class Main { public static String format(BigDecimal num) { NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(100); nf.setMinimumFractionDigits(0);/*from www.j a va2 s .co m*/ nf.setGroupingUsed(false); return nf.format(num).replace(",", "."); // also replace fraction separator to '.' dot for different locales } }