How can I format an int to contain a set amount of characters? If the set amount of characters is 6 and the int == 12345 then it should become 012345.
Created May 8, 2012
Byron Tymvios
int iValue = 12345;
java.text.DecimalFormat df = new java.text.DecimalFormat("00000");
String sResult = df.format(iValue);
System.out.println("Format: " + sResult);
This should now output 012345
For further documentation on formating numeric primitives have a look at the API documentation for java.text.DecimalFormat.