Here you can find the source of formatLong(long inLong, int inLen, boolean inComma, int inCommaPos)
public static final String formatLong(long inLong, int inLen, boolean inComma, int inCommaPos)
//package com.java2s; public class Main { /**//from w w w . j a v a2 s .c om * This method is to format the long. **/ public static final String formatLong(long inLong, int inLen, boolean inComma, int inCommaPos) { String outString = ""; int countComma = 0; long tempLong; boolean fNegative = false; if (inLong < 0) { fNegative = true; inLong = inLong * (-1); } if (inLong == 0) outString = "0"; else { while (inLong > 0) { if (inComma && countComma == inCommaPos) { outString = "," + outString; countComma = 0; } tempLong = inLong % 10; outString = Long.toString(tempLong) + outString; inLong = (long) (inLong / 10); countComma++; } } if (fNegative) outString = "-" + outString; return outString; } /** * This method is to format the long. **/ public static final String formatLong(long inLong, boolean inComma, int inCommaPos) { String outString = ""; int countComma = 0; long tempLong; boolean fNegative = false; if (inLong < 0) { fNegative = true; inLong = inLong * (-1); } if (inLong == 0) outString = "0"; else { while (inLong > 0) { if (inComma && countComma == inCommaPos) { outString = "," + outString; countComma = 0; } tempLong = inLong % 10; outString = Long.toString(tempLong) + outString; inLong = (long) (inLong / 10); countComma++; } } if (fNegative) outString = "-" + outString; return outString; } }