Here you can find the source of formatToString(Double v)
public static String formatToString(Double v)
//package com.java2s; import java.text.DecimalFormat; public class Main { public static String formatToString(Double v) { if (v == null) { return ""; }/*w w w .j a v a 2s . com*/ try { DecimalFormat sos = new DecimalFormat("###.####"); String s = sos.format(v); return s; } catch (Exception e) { return v.toString(); } } public static String formatToString(Double v, String format) { if (v == null) { return ""; } try { DecimalFormat sos = new DecimalFormat(format); String s = sos.format(v); return s; } catch (Exception e) { return v.toString(); } } }