Parse and format to hexadecimal
public class Main { public static void main(String[] argv) throws Exception { int i = Integer.parseInt("3ff", 16); String s = Integer.toString(i, 16); System.out.println(s); } }