<tutorialjinni.com/>

JAVA Zero Pad Int

Posted Under: JAVA, Snippets on May 4, 2020
Java code snippet to append/pad Zero on the left of an Integer. For that we need to use String format method like this
int integer = 15;
String paddedInteger = String.format("%03d", integer);
System.out.println(paddedInteger);
This explained in the images below.

pad 0s in java


imgae