Java Utililty Methods Integer to

List of utility methods to do Integer to

Description

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

Method

voidintToSortableBytes(int value, byte[] result, int offset)
Encodes an integer value such that unsigned byte order comparison is consistent with Integer#compare(int,int)
value ^= 0x80000000;
result[offset] = (byte) (value >> 24);
result[offset + 1] = (byte) (value >> 16);
result[offset + 2] = (byte) (value >> 8);
result[offset + 3] = (byte) value;
StringBufferintToStringBuffer(final int param, final int len)
convert an integer to a StringBuffer (left padding).
StringBuffer temp = new StringBuffer(Integer.toString(param));
leftPadding(temp, len, ' ');
return temp;
StringintToStringWithZeroFill(int intValue, int width)
Convert integer to string with left zero fill.
String s = new Integer(intValue).toString();
if (s.length() < width)
    s = dupl('0', width - s.length()) + s;
return s;
byteintToTime(int time)
Convert an int value to a timecode byte that can be used in sending a seekTimecode command.
double timeD = (double) time;
int tens = (int) Math.floor(timeD / 10D) * 10;
int ones = time - tens;
return (byte) (((tens / 10) << 4) + ones);
StringintToTime(int value)
int To Time
int hour = value;
String ampm = "am";
if (hour > 12) {
    hour -= 12;
    if (hour != 12)
        ampm = "pm";
if (hour == 0)
...
StringintToTriplePlace(int i)
int To Triple Place
int place = i;
switch (place) {
case 0:
    return "subject";
case 1:
    return "predicate";
case 2:
    return "object";
...
voidintToTwoByte(int value, byte[] destination, int offset)
int To Two Byte
if ((value < 0) || (value > MAX_16BITS))
    throw new IllegalArgumentException(String.format(ERR_VALUE_OOB, value));
destination[offset] = (byte) ((value & 0x0000FF00L) >> 8);
destination[offset + 1] = (byte) ((value & 0x000000FFL));
byte[]intToTwoBytes(int value)
This function converts integer to two bytes
byte[] result = new byte[2];
if ((value > Math.pow(2, 31)) || (value < 0)) {
    throw new Exception("Integer value " + value + " is larger than 2^31");
result[0] = (byte) ((value >>> 8) & 0xFF);
result[1] = (byte) (value & 0xFF);
return result;
StringintToTwoDigitString(int integer)
Create two digit string with leading zeros from integer.
String number = String.valueOf(integer);
int numberLength = number.length();
if (numberLength == 2) {
    return number;
} else if (numberLength == 1) {
    return "0" + number;
throw new IllegalArgumentException(
...
StringintToTwoHexString(final int value)
Convert an integer to a two character Hex string, with leading zero.
final StringBuffer buffer;
final String strHex;
buffer = new StringBuffer();
strHex = Integer.toHexString(value & 0xFF);
if (strHex.length() == 0) {
    buffer.append("00");
} else if (strHex.length() == 1) {
    buffer.append("0");
...