Here you can find the source of formatDouble(DecimalFormat fmt, double value)
public static String formatDouble(DecimalFormat fmt, double value)
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; public class Main { public static String formatDouble(DecimalFormat fmt, double value) { if (Double.isNaN(value)) { return "NaN"; } else if (Double.isInfinite(value)) { if (value > 0) { return "+Inf"; } else { return "-Inf"; }/*from w w w . j a v a2 s . c o m*/ } else { return fmt.format(value); } } }