public class Mydate {
int year;
int month;
int day;
public Mydate(int year,int month,int day){
this.year = year;
this.month = month;
this.day = day;
}
public void newdate(){
System.out.println(this.year+"年"+this.month+"月"+this.day+"日");
if(year<0||month<=0||day<=0||month>12||day>31)
System.out.println("输入的是非法日期");
if(month==4||month==6||month==9||month==11&&day>30)
System.out.println("输入的是非法日期");
if(month==2 && ((year%4 == 0 && year%100 != 0) || (year%400 == 0))){
if(day>29)
System.out.println("输入的是非法日期");
}
}
public static void main (String[] args) {
Mydate date1 = new Mydate(2008,2,29);
date1.newdate();
}
}