I need to add zeros to the left of a number until it gets six digits.
Ex. If the number is 5, it should be formatted as 000005.
Can someone please let me know how to achieve this in Java?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
String.format("%05d", 5);
You can use,
String.format("%06d", your_number);
for zero-padding with length=6.
More info on: http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html