Here you can find the source of formatDouble(double d, int maximumFractionDigits)
public static String formatDouble(double d, int maximumFractionDigits)
//package com.java2s; //License from project: Apache License import java.text.NumberFormat; public class Main { public static String formatDouble(double d, int maximumFractionDigits) { NumberFormat format = NumberFormat.getNumberInstance(); format.setMaximumFractionDigits(maximumFractionDigits); return format.format(d); }//from w w w .j a v a2s . co m }