A quick recipe, converting an int or long like 65 to a string like 000041. It’s useful for converting integer RGB colors to the common #FFBBCC kind of web encoded colors.
To hex string example
int number = 65;
String hexString = String.format("%06X", number);