Here you can find the source of format(double number)
public static String format(double number)
//package com.java2s; public class Main { public static String format(double number) { if (number == (int) number) return String.valueOf((int) number); else/*from w w w . j a va 2 s .c o m*/ return String.valueOf(number); } }