java help 2 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

java help 2

public String toMilitary() { return String.format("%02d:%02d:%02d", getHour(), getMinute(), getSecond()); what does code %02d mean?

22nd Jul 2017, 5:27 PM
Rsps Ottoman
Rsps Ottoman - avatar
1 Answer
+ 1
% means it is to be a literal 0 is the padding flag (result will be 0 padded) 2 is the width of digits to be output d means the type passed in is a decimal (base 10) integer https://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html
22nd Jul 2017, 5:35 PM
ChaoticDawg
ChaoticDawg - avatar