java int to hex fixed length

Java
//You can replace X with x to get lower case hex characters
//Replace the 2 with the amount of digits you want
String.format("%02X", value);
Source

Also in Java: