tags:

views:

136

answers:

3

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
}
+4  A: 

You can use java.util.Formatter or String.format

String.format("%02d", somenumber)
The MYYN
`String.format("%02d/%02d%n",month,day);`
Andreas_D
Is this the zero-pad flag
daddycardona
+1  A: 
for (int i=0; i<19; i++)
   System.out.format("i: %02d\n", i);
+1  A: 
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
}
ZZ Coder