Here you can find the source of formatInteger(int inInt, int inLen, boolean inComma, int inCommaPos)
public static final String formatInteger(int inInt, int inLen, boolean inComma, int inCommaPos)
//package com.java2s; public class Main { /**/* w w w .ja v a 2 s .co m*/ * This method is to format the integer. **/ public static final String formatInteger(int inInt, int inLen, boolean inComma, int inCommaPos) { String outString = ""; int countComma = 0, tempInt; boolean fNegative = false; if (inInt < 0) { fNegative = true; inInt = inInt * (-1); } if (inInt == 0) outString = "0"; else { while (inInt > 0) { if (inComma && countComma == inCommaPos) { outString = "," + outString; countComma = 0; } tempInt = inInt % 10; outString = Integer.toString(tempInt) + outString; inInt = (int) (inInt / 10); countComma++; } } if (fNegative) outString = "-" + outString; return outString; } }