Here you can find the source of formatNumberByMaxFracUseGrp(BigDecimal number, int val)
public static String formatNumberByMaxFracUseGrp(BigDecimal number, int val)
//package com.java2s; import java.math.BigDecimal; import java.text.NumberFormat; public class Main { public static String formatNumberByMaxFracUseGrp(BigDecimal number, int val) { NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(val); nf.setGroupingUsed(true);//from w ww. j a va2 s. co m return nf.format(number); } }