Java tutorial
//package com.java2s; public class Main { public static String toHexString(long i, int size) { String value = Long.toHexString(i); while (value.length() < size) { value = "0" + value; } return value; } }