Here you can find the source of formatNum(double d)
public static String formatNum(double d)
//package com.java2s; import java.text.DecimalFormat; public class Main { public static String formatNum(double d) { DecimalFormat df = new DecimalFormat("####,##0.00"); String result = df.format(d); if (".00".equals(result)) { result = "0" + result; }/*from w w w.j a va 2 s. com*/ return result; } }