Here you can find the source of toHEX(int value)
public static String toHEX(int value)
//package com.java2s; /*/*from ww w. java 2 s .co m*/ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. */ public class Main { public static String toHEX(int value) { return toHEX(value, 4); } public static String toHEX(int value, int count) { StringBuffer buf = new StringBuffer(); String hex = Integer.toHexString(value); int hlen = hex.length(); while (count > hlen) { buf.append("0"); count--; } buf.append(hex.toUpperCase()); return buf.toString(); } }