Java Utililty Methods Integer Format

List of utility methods to do Integer Format

Description

The list of methods to do Integer Format are organized into topic(s).

Method

intformatInt(String value, int defaultValue)
format Int
try {
    if (isNotEmpty(value)) {
        return Integer.valueOf(value).intValue();
    } else {
        return defaultValue;
} catch (Exception e) {
    return defaultValue;
...
StringformatInt2(int n)
Formats an integer to 2 digits, as used for example in time.
if (n > 9) {
    return Integer.toString(n);
return "0" + n;
StringformatInt64(long val)
format Int
String retval = Long.toString(val);
return (retval);
StringformatIntAsDottedOctet(int value)
format Int As Dotted Octet
return Integer.toString((value >> 24) & 0xff) + "." + Integer.toString((value >> 16) & 0xff) + "."
        + Integer.toString((value >> 8) & 0xff) + "." + Integer.toString((value >> 0) & 0xff);
StringformatIntAsIpAddress(final int address)
format Int As Ip Address
StringBuilder buffer = new StringBuilder();
formatIntAsIpAddress(buffer, address);
return buffer.toString();
StringformatInteger(byte[] btValue, int iOffset, int iLength)
format Integer
int iLastOffset = iOffset + iLength;
if (btValue.length < iLastOffset || iLength < 1)
    return "";
int iValue = 0;
for (int iIndex = iOffset; iIndex < iLastOffset; iIndex++) {
    iValue <<= 8;
    iValue |= (btValue[iIndex] & 0xFF);
return String.valueOf(iValue);
StringformatInteger(int i, int j)
Format integer.
String frm = "%0" + j + "d";
String s;
s = String.format(frm, i);
return s;
StringformatInteger(int inInt, int inLen, boolean inComma, int inCommaPos)
This method is to format the integer.
String outString = "";
int countComma = 0, tempInt;
boolean fNegative = false;
if (inInt < 0) {
    fNegative = true;
    inInt = inInt * (-1);
if (inInt == 0)
...
StringformatInteger(int integer, int length)
format Integer
String curInt = ("" + integer);
while (curInt.length() < length) {
    curInt = " " + curInt;
return curInt;
StringformatInteger(int value, int length)
format Integer
StringBuffer buffer;
buffer = new StringBuffer(length);
for (int i = length - ("" + value).length(); i > 0; i--) {
    buffer.append("0");
buffer.append(value);
return buffer.toString();