Here you can find the source of longToHex(long l, int length)
public static String longToHex(long l, int length)
//package com.java2s; public class Main { public static String longToHex(long l, int length) { String temp = Long.toHexString(l); while (temp.length() < length * 2) { temp = "0" + temp; }//from w w w. jav a 2 s . c o m return temp; } }