List of utility methods to do Long to
String | longToDB(long val) long To DB String s = Long.toString(val); int l = s.length(); String dbVal = ""; if (s.length() < 10) { dbVal = "0"; return dbVal + Integer.toString(l) + s; |
byte[] | longToEightBytes(final long value) long To Eight Bytes byte[] b = new byte[8]; int shift = 56; for (int i = 0; i < 8; i++) { b[i] = (byte) ((value >>> shift) & 0xff); shift -= 8; return b; |
byte[] | longToFourBytes(long value) This function converts longToFourBytes byte[] result = new byte[4]; result[0] = (byte) ((value >>> 24) & 0xFF); result[1] = (byte) ((value >>> 16) & 0xFF); result[2] = (byte) ((value >>> 8) & 0xFF); result[3] = (byte) (value & 0xFF); return result; |
int | longToFrontInt(long data) long To Front Int data = data >> 32; int result = (int) data; return result; |
byte[] | longToLex(long v) Converts a regular java long to a lexicographical sortable long v ^= c64; return longBytes(v, new byte[8], 0); |
void | longToLittleEndianBytes(long value, byte[] destination, int offset, int length) Converts a long to the array of bytes in the little endian format. int shiftBits = 0; for (int i = 0; i < length; i++) { destination[offset + i] = (byte) ((value >> shiftBits) & 0xFF); shiftBits += 8; |
String | longToN62(long l) long To N return longToNBuf(l, N62_CHARS).reverse().toString();
|
String | longToName(long l) Converts long to name string. int i = 0; char ac[] = new char[12]; while (l != 0L) { long l1 = l; l /= 37L; ac[11 - i++] = VALID_CHARS[(int) (l1 - l * 37L)]; return new String(ac, 12 - i, i); ... |
StringBuilder | longToNBuf(long l, char[] chars) long To N Buf int upgrade = chars.length; StringBuilder result = new StringBuilder(); int last; while (l > 0) { last = (int) (l % upgrade); result.append(chars[last]); l /= upgrade; return result; |
byte[] | longToNetworkByteOrderArray(long addr) Convert an host byte order long to byte array in network byte order. return new byte[] { (byte) (addr >>> 24), (byte) (addr >>> 16), (byte) (addr >>> 8), (byte) addr }; |