Here you can find the source of LongToString(long value)
public static String LongToString(long value)
//package com.java2s; public class Main { private static final String HexAlphabet = "0123456789ABCDEF"; public static String LongToString(long value) { if (value == Long.MIN_VALUE) { return "-9223372036854775808"; }/*from w w w .jav a 2s .c o m*/ if (value == 0) { return "0"; } boolean neg = value < 0; char[] chars = new char[24]; int count = 0; if (neg) { chars[0] = '-'; ++count; value = -value; } while (value != 0) { char digit = HexAlphabet.charAt((int) (value % 10)); chars[count++] = digit; value /= 10; } if (neg) { ReverseChars(chars, 1, count - 1); } else { ReverseChars(chars, 0, count); } return new String(chars, 0, count); } private static void ReverseChars(char[] chars, int offset, int length) { int half = length >> 1; int right = offset + length - 1; for (int i = 0; i < half; i++, right--) { char value = chars[offset + i]; chars[offset + i] = chars[right]; chars[right] = value; } } }