Here you can find the source of formatDecimal(double dtSource, String nbit)
public static String formatDecimal(double dtSource, String nbit)
//package com.java2s; //License from project: Apache License public class Main { public static String formatDecimal(double dtSource, String nbit) { java.text.DecimalFormat formatter = null; try {//from w w w .j a v a 2s. c o m formatter = new java.text.DecimalFormat("#,###." + nbit); } catch (Exception e) { System.out.println(e.getMessage()); } return formatter.format(dtSource); } }