Java tutorial
//package com.java2s; public class Main { public static String tohex(int i) { if (i < 16) { return "0" + Integer.toHexString(i).toUpperCase(); } return Integer.toHexString(i).toUpperCase(); } }