Here you can find the source of formatDouble(final double num)
public static String formatDouble(final double num)
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; public class Main { public static String formatDouble(final double num) { final DecimalFormat df = new DecimalFormat("#,###.00"); boolean hasFloating = false; if (num - (int) num != 0) { hasFloating = true;// w ww .j a v a 2 s . co m } if (hasFloating) { return df.format(num); } else { return String.valueOf((int) num); } } }