Java Utililty Methods Hex Calculate

List of utility methods to do Hex Calculate

Description

The list of methods to do Hex Calculate are organized into topic(s).

Method

StringtoHexString(int i)
to Hex String
char ac[] = new char[32];
int j = 32;
byte byte0 = 16;
int k = byte0 - 1;
do {
    ac[--j] = HEX_DIGITS[i & k];
    i >>>= 4;
} while (i != 0);
...
StringtoHexString(int i)
to Hex String
char[] buffer = new char[8];
int index = 8;
do {
    buffer[--index] = _HEX_DIGITS[i & 15];
    i >>>= 4;
} while (i != 0);
return new String(buffer, index, 8 - index);
StringtoHexString(int i)
Convert an integer to a 16-digit hex string.
String s = Integer.toHexString(i).toUpperCase();
if (s.length() < 8)
    return "00000000".substring(8 - s.length()) + s;
else
    return s;
StringtoHexString(int i)
to Hex String
String hex = Integer.toHexString(i);
if (hex.length() == 1) {
    return "0" + hex;
} else {
    return hex;
StringtoHexString(int i, int digits)
Converts int value to hex string.
String hexString = Integer.toHexString(i);
int len = hexString.length();
StringBuffer result = new StringBuffer();
for (int j = 0; j < digits; j++) {
    if (len < (digits - j))
        result.append("0");
    else
        result.append(hexString.charAt(len - digits + j));
...
StringtoHexString(int input)
Converts the given int to a Big Endian hex string
char[] hex = new char[8];
int index = 0;
for (int i = 0; i < 4; i++) {
    final int b = (input >>> (24 - 8 * i)) & 0xFF;
    hex[index++] = HEX_CHAR_TABLE[b >>> 4];
    hex[index++] = HEX_CHAR_TABLE[b & 0xF];
String result = null;
...
StringtoHexString(int iValue)
to Hex String
String str = Integer.toHexString(iValue);
if (str.length() == 1)
    return "0" + str;
else if (str.length() == 8)
    return str.substring(6, 8);
return str;
StringtoHexString(int n)
to Hex String
return String.format("0x%8s", Integer.toHexString(n)).replace(' ', '0').toUpperCase();
StringtoHexString(int number, int digit)
to Hex String
String result = "";
while (digit-- > 0) {
    int n = number % 16;
    number /= 16;
    result = HEX_LETTER.substring(n, n + 1) + result;
return result;
StringtoHexString(int r, int g, int b, int a)
Transforms a color rgba components to their hex string representation argb coded.
StringBuilder hexString = new StringBuilder("0x");
hexString.append(formatByteToPaddedHex(a, 2));
hexString.append(formatByteToPaddedHex(r, 2));
hexString.append(formatByteToPaddedHex(g, 2));
hexString.append(formatByteToPaddedHex(b, 2));
return hexString.toString();