Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you print two places exactly using zero-pad flag in a print statement

Tags:

java

printf

if wanted to make a this method print using zero pad how do you do so

int month, day;

public void  printNumeric()
{
  System.out.printf("month +"/" +day +" \n");
  // i would like the month if it is 5 to be 05 same thing with the day
}
like image 630
daddycardona Avatar asked Nov 26 '09 13:11

daddycardona


1 Answers

int month, day;

public void  printNumeric()
{
  System.out.printf("%02d/%02d\n", month, day);
  // i would like the month if it is 5 to be 05 same thing with the day
}
like image 62
ZZ Coder Avatar answered Oct 23 '22 08:10

ZZ Coder