List of utility methods to do Integer to Hex
String | integerToHex(final Object value, final int desimals) integer To Hex String str = Long.toString(((Number) value).longValue(), 16).toUpperCase(); if (desimals == 0 || str.length() == zeroes.length()) { return str; return zeroes.substring(0, desimals - str.length()) + str; |
String | integerToHex(final Object value, final int desimals) integer To Hex long tmp; if (value instanceof Byte) { tmp = ((Byte) value).byteValue() & 0xFF; } else if (value instanceof Short) { tmp = ((Short) value).shortValue() & 0xFFFF; } else if (value instanceof Long) { tmp = ((Long) value).longValue() & 0xFFFFFFFF; } else { ... |
String | integerToHex(int val) integer To Hex return Integer.toHexString(val).toUpperCase(); |
String | integerToHexShort(int value) integer To Hex Short return Integer.toHexString(0x10000 | value).substring(1).toUpperCase();
|
String | integerToHexString(final int aValue, final int aFieldWidth) converts an integer to a hex string with leading zeros final long mask = (long) (Math.pow(16.0, aFieldWidth) - 1L); StringBuilder sb = new StringBuilder(Long.toHexString(aValue & mask)); int numberOfLeadingZeros = Math.max(0, aFieldWidth - sb.length()); for (; numberOfLeadingZeros > 0; numberOfLeadingZeros--) { sb.insert(0, '0'); return sb.toString(); |
String | integerToHexString(int value, int minBytes) Converts the given integer into an hexadecimal string. if (minBytes <= 0) throw new IllegalArgumentException("Minimum number of bytes must be greater than 0."); String f = String.format("%%0%dX", minBytes * 2); return String.format(f, value); |
String | intToFixedLengthHex(int value, int length) Takes value and return its HEX value prefixed with zeros .
String str = Integer.toHexString(value); StringBuilder paddedStr = new StringBuilder(); if (str.length() < length) { for (int i = 0; i < length - str.length(); i++) paddedStr.append('0'); paddedStr.append(str); return paddedStr.toString(); ... |
String | intToFixedLengthHexString(int i, int length) Converts an integer into a fixed, zero-padded hexadecimal string representation. String s = Integer.toHexString(i); String pad = "0"; while (s.length() < length) { s = pad.concat(s); if (s.length() > length) { s = s.substring(0, length); return s.toUpperCase(); |
String | intToHex(int a) int To Hex byte[] b = new byte[4]; intToBytes(a, b, 0); return bytesToHex(b); |
String | intToHex(int i) Utility method to convert an int into hex, padded to two characters. String prelim = Integer.toHexString(i); if (prelim.length() < 2) { prelim = "0" + prelim; return prelim; |