Here you can find the source of formatDouble(Object obj)
public final static String formatDouble(Object obj)
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; public class Main { public final static String formatDouble(Object obj) { DecimalFormat fmt = new DecimalFormat("#,##0.00"); String str = String.valueOf(obj); if (obj instanceof Double) { return fmt.format(obj); } else if (str.matches("^[-\\+]?\\d+(\\.\\d+)?$")) { return fmt.format(Double.valueOf(str)); } else {/*from w w w . java 2s. c om*/ return toStringWithOutNull(str); } } public final static String toStringWithOutNull(Object obj) { return obj == null ? "" : String.valueOf(obj); } }