Here you can find the source of formatDouble(double number)
public static double formatDouble(double number)
//package com.java2s; //License from project: Apache License import java.text.DecimalFormat; public class Main { public static double formatDouble(double number) { DecimalFormat fmt = new DecimalFormat("#.##"); if (Double.isNaN(number)) { return Double.NaN; } else {//from ww w. j a va 2 s . c o m return Double.parseDouble((fmt.format(number))); } } }