Here you can find the source of formatNumber(double number, int decimal)
public static String formatNumber(double number, int decimal)
//package com.java2s; //License from project: Apache License import java.text.NumberFormat; public class Main { public static final NumberFormat NUM_FORMAT = NumberFormat .getInstance(); public static String formatNumber(double number, int decimal) { NUM_FORMAT.setMaximumFractionDigits(decimal); NUM_FORMAT.setMinimumFractionDigits(decimal); return NUM_FORMAT.format(number).replace(",", ""); }//from w ww . jav a 2s . c o m }