Here you can find the source of format(double number, String fmt)
public static String format(double number, String fmt)
//package com.java2s; //License from project: Open Source License import java.math.BigDecimal; import java.text.DecimalFormat; public class Main { public static String format(long number, String fmt) { return new DecimalFormat(fmt).format(number); }//from w ww .j a va2 s.c o m public static String format(double number, String fmt) { return new DecimalFormat(fmt).format(number); } public static String format(Object number, String fmt) { if (number instanceof String) { return new DecimalFormat(fmt).format(new BigDecimal( (String) number)); } else { return new DecimalFormat(fmt).format(number); } } }