public static String formatNumber(final BigDecimal number,final int fractionDigits,final boolean useGrouping){
  final NumberFormat numberFormat=NumberFormat.getInstance();
  numberFormat.setMinimumFractionDigits(fractionDigits);
  numberFormat.setMaximumFractionDigits(fractionDigits);
  numberFormat.setGroupingUsed(useGrouping);
  return numberFormat.format(number.doubleValue());
}

public static String formatNumber ( final BigDecimal number , final int fractionDigits , final boolean useGrouping ) { final NumberFormat numberFormat = NumberFormat . getInstance ( ) ; numberFormat . setMinimumFractionDigits ( fractionDigits ) ; numberFormat . setMaximumFractionDigits ( fractionDigits ) ; numberFormat . setGroupingUsed ( useGrouping ) ; return numberFormat . format ( number . doubleValue ( ) ) ; }
formats a given number with given number of fraction digits < br > e . g . formatnumber ( 1000 , 2 , false ) will return 1000 . 00 < br > formatnumber ( 1000 , 2 , true ) will return 1 , 000 . 00 < br >
