Here you can find the source of formatNumber(double decimal)
public static String formatNumber(double decimal)
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; public class Main { public static String formatNumber(double decimal) { DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(); symbols.setGroupingSeparator(' '); symbols.setDecimalSeparator(','); DecimalFormat formatter = new DecimalFormat("###,###.###", symbols); formatter.setMaximumFractionDigits(3); formatter.setMinimumFractionDigits(3); return formatter.format(decimal); }//from w w w . j a va 2 s. c o m }