public class YmDay {
public static void main(String[] args) {
int year = 2009, month = 1, day = 8;
int m2;
if (year % 100 == 0 && year % 400 == 0 || year % 4 == 0
&& year % 100 != 0)
m2 = 29;
else
m2 = 28;
System.out.println("今年二月有:" + m2 + "天");
switch (month) {
case 1:
break;
case 2:
day = day + 31;
break;
case 3:
day = day + m2 + 31;
break;
case 4:
day = day + 31 + m2 + 31;
break;
case 5:
day = day + 30 + 31 + m2 + 31;
break;
case 6:
day = day + 31 + 30 + 31 + m2 + 31;
break;
case 7:
day = day + 30 + 31 + 30 + 31 + m2 + 31;
break;
case 8:
day = day + 31 + 30 + 31 + 30 + 31 + m2 + 31;
break;
case 9:
day = day + 31 + 31 + 30 + 31 + 30 + 31 + m2 + 31;
break;
case 10:
day = day + 30 + 31 + 31 + 30 + 31 + 30 + 31 + m2 + 31;
break;
case 11:
day = day + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31 + m2 + 31;
break;
case 12:
day = day + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31 + m2 + 31;
break;
default:
System.out.println("一年中只有十二个月");
break;
}
System.out.printf("%d年%d月8日是一年中的第%d天", year, month, day);
}//  今年二月有:28天    2009年1月8日是一年中的第8天

}