Wednesday, March 7, 2018

string formatting - How do I add left-padded zeros to a number in Java?




I have an integer 100, how do I format it to look like 00000100 (always 8 digits long)?


Answer



Try this:



String formattedNumber = String.format("%08d", number);

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...