Convert from decimal to hexadecimal with leading zeroes and uppercase in Java
Description
The following code shows how to convert from decimal to hexadecimal with leading zeroes and uppercase.
Example
//w w w.j a va 2s . c o m
public class Main {
public static void main(String[] args) throws Exception {
String s = Integer.toHexString(0x10000 | 2).substring(1);
System.out.println(s);
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »