Convert from decimal to hexadecimal with leading zeroes and uppercase
public class Main { public static void main(String[] args) throws Exception { System.out.print(Integer.toHexString(0x10000 | i).substring(1).toUpperCase()); } }