public static String toHexString(Number n) {
		if (n == null)
			return "null";
		
		byte[] bytes = new byte[8];
        ByteBuffer bytesBuffer = ByteBuffer.wrap(bytes);
        LongBuffer longBuffer = bytesBuffer.asLongBuffer();
        longBuffer.put(0, n.longValue());

		StringBuilder sb = new StringBuilder(16);
		for (int i = 0; i < bytes.length; i++) {
			int b = bytes[i] & 0xFF;
			if (b != 0 || sb.length() > 0 || i == (bytes.length - 1))
				sb.append(HEX_CHARS.charAt(b >> 4)).append(HEX_CHARS.charAt(b & 0x0F));
		}
		return sb.toString();
	}