public class Date
{
public Date(int m, int d, int y)
{
day = nextDay(m,d,y);
if(day == 1)
month = nextMonth(m,d);
if (m == 1 && d == 1)
y = nextYear(y);
System.out.println(" " + m + "/"+ d+"/"+y):
}
public static int nextDay(int m, int d, int y)
{
switch(d){
case 28:
if(y%4 == 0)
++d;
else
if(m == 2)
d = 1;
break;
case 29:
if(m == 2)
d = 1;
break;
case 31: d = 1; break;
default: ++d; break;
}
return day;
}
public static int nextMonth(int m, int d)
{
if( m == 12 & d == 1)
m = 1;
else
if (d == 1)
++m;
return m;
}
public static int nextYear(int y)
{
return ++y;
}
}
===========================
public class DateTest
{
public static void main(String[] args)
{ int m,d,y;
m = 2;d=28;y = 2011;
System.out.println(" " + m + "/"+ d+"/"+y);// this line should give 2/28/2011
new Date(m,d,y);
System.out.println(" " + m + "/"+ d+"/"+y);// this line should give 3/1/2011
Date.nextDay(m, d, y); System.out.println(" " + m + "/"+ d+"/"+y);//
this line should give 3/2/2011
}
}