How do you left pad an int with zeros when converting to a String in java?
int
String
I\'m basically looking to pad out integers up to 9999
9999
Use the class DecimalFormat, like so:
NumberFormat formatter = new DecimalFormat("0000"); //i use 4 Zero but you can also another number System.out.println("OUTPUT : "+formatter.format(811));
OUTPUT : 0000811