public static String formatNumber(final long number){
  long divided=number;
  final StringBuffer sb=new StringBuffer();
  while (divided > 1000) {
    long rest=divided % 1000;
    sb.insert(0," " + String.format("%03d",rest));
    divided=divided / 1000;
  }
  long rest=divided % 1000;
  sb.insert(0,rest);
  return sb.toString();
}

public static String formatNumber ( final long number ) { long divided = number ; final StringBuffer sb = new StringBuffer ( ) ; while ( divided > 1000 ) { long rest = divided % 1000 ; sb . insert ( 0 , " " + String . format ( "%03d" , rest ) ) ; divided = divided / 1000 ; } long rest = divided % 1000 ; sb . insert ( 0 , rest ) ; return sb . toString ( ) ; }
formats the given number into one where thousands are separated by a space .
