Here you can find the source of toHex(long i)
public static String toHex(long i)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w w w . j a va 2s. c o m*/ * Converts a number to a hex value * * @param i The value * @param r1 Should the string be fancy? (0xYYYY) * @param r0 Length of fancieness * @return The string */ public static String toHex(long i, int r0, boolean r1) { String h = Long.toHexString(i).toUpperCase(); while (h.length() < r0 && r1) { h = 0 + h; } return (r1 ? "0x" : "") + h; } public static String toHex(long i) { return toHex(i, 2, false); } }