Here you can find the source of objectToString(Object obj, DecimalFormat fmt)
public static final String objectToString(Object obj, DecimalFormat fmt)
//package com.java2s; //License from project: Apache License import java.text.DecimalFormat; public class Main { public static final String objectToString(Object obj, DecimalFormat fmt) { fmt.setDecimalSeparatorAlwaysShown(false); if (obj instanceof Double) return fmt.format(((Double) obj).doubleValue()); if (obj instanceof Long) return fmt.format(((Long) obj).longValue()); else//from w ww . j a va 2 s. c o m return obj.toString(); } }