Here you can find the source of toFormattedNumber(Object value)
public static String toFormattedNumber(Object value)
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; public class Main { static DecimalFormat DEFAULT_DECIMAL_FORMATTER = new DecimalFormat("#.####"); public static String toFormattedNumber(Object value) { if (value == null) { return ""; }/*from w w w . j a v a2s. c om*/ if (value instanceof Double || value instanceof Float) { return DEFAULT_DECIMAL_FORMATTER.format(value); } return value.toString(); } }