Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what do these symbolic strings mean: %02d %01d?

Tags:

java

printf

I'm looking at a code line similar to:

sprintf(buffer,"%02d:%02d:%02d",hour,minute,second); 

I think the symbolic strings refer to the number of numeric characters displayed per hour, minute etc - or something like that, I am not entirely certain.

Normally I can figure this sort of thing out but I have been unable to find any useful reference searching "%02d %01d" on google. Anyone able to shed some light on this for me?

like image 949
dRef90 Avatar asked Jul 31 '10 10:07

dRef90


1 Answers

Instead of Googling for %02d you should have been searching for sprintf() function.

%02d means "format the integer with 2 digits, left padding it with zeroes", so:

 Format  Data   Result %02d    1      01 %02d    11     11 
like image 57
Anax Avatar answered Oct 02 '22 12:10

Anax