Logo

Programming-Idioms

History of Idiom 156 > diff from v11 to v12

Edit summary for version 12 by bert:
[Java] forgot assignment

Version 11

2019-09-26, 18:06:28

Version 12

2019-09-26, 18:07:03

Idiom #156 Format integer with zero-padding

Assign to string s the value of integer i in 3 decimal digits. Pad with zeros if i < 100. Keep all digits if i1000.

Idiom #156 Format integer with zero-padding

Assign to string s the value of integer i in 3 decimal digits. Pad with zeros if i < 100. Keep all digits if i1000.

Extra Keywords
pad leading fixed width
Extra Keywords
pad leading fixed width
Code
String.format("%03d", i);
Code
String s = String.format("%03d", i);