Here you can find the source of toHex(int n, int s)
protected static String toHex(int n, int s)
//package com.java2s; //License from project: Apache License public class Main { protected static String toHex(int n, int s) { String str = "0000000000000000" + Integer.toHexString(n); return str.substring(str.length() - s); }//from w ww . j a va2s .c o m }