public class Date
{
private int day,
month,
year;
public Date(int day, int month, int year)
{
this.day=day;
this.month=month;
this.year=year;
}
public int getday()
{
return day;
}
public int getmon()
{
return month;
}
public int getyear()
{
return year;
}
public void setd(int day)
{
this.day=day;
}
public void setm(int month)
{
this.month=month;
}
public void sety(int year)
{
this.year=year;
}
public String toString()
{
return " "+getday()+"/"+getmon()+"/"+getyear();
}
}
How to make the toString
method to return 2 leading 0? So that if I call it in the main if I call the toString
method it will print
The output of that is 2/10/199
my expected output
02/10/1999