Java tutorial
//package com.java2s; import java.text.DecimalFormat; import java.text.NumberFormat; public class Main { private static NumberFormat numberFormat = new DecimalFormat("###,###"); public static String numberFormat(long number) { String numberString = String.valueOf(number); String returnString = ""; if (numberString.length() > 4) { returnString = numberString.substring(0, numberString.length() - 4); } else if (numberString.length() == 4) { returnString = numberString.substring(0, 1) + "," + numberString.substring(1, 4); } else { returnString = numberString; } return returnString; } }