Java tutorial
//package com.java2s; 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 return obj.toString(); } }