class HexEncode {

    public static String longToHexString(long val) {
        char[] arr = Long.toHexString(val).toCharArray();
        StringBuffer buf = new StringBuffer();
        // prepend the right number of leading zeros
        int index = 0;
        for (; index < 16 - arr.length; index++) {
            buf.append("0");
            if ((index & 0x01) == 1) {
                buf.append(":");
            }
        }
        for (int j = 0; j < arr.length; j++) {
            buf.append(arr[j]);
            if ((index + j & 0x01) == 1 && j < arr.length - 1) {
                buf.append(":");
            }
        }
        return buf.toString();
    }

    private  HexEncode();

}