Here you can find the source of doubleToString(double value, int fractionDigits)
public static String doubleToString(double value, int fractionDigits)
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; public class Main { public static String doubleToString(double value, int fractionDigits) { return doubleToString(value, 0, fractionDigits); }/* w w w . j av a2s . c om*/ public static String doubleToString(double value, int minFractionDigits, int maxFractionDigits) { DecimalFormat numberFormat = new DecimalFormat(); numberFormat.setMinimumFractionDigits(minFractionDigits); numberFormat.setMaximumFractionDigits(maxFractionDigits); return numberFormat.format(value); } }