Java 求今天日期

来源:互联网 发布:云资源管理平台软件 编辑:程序博客网 时间:2024/05/01 11:35
public class  aa1
{
public static void main(String[] args) 
{   int week;
String marks="weeks";
switch(week){
case 1:marks="一";break;
case 2:marks="二";break;
        case 3:marks="三";break;
        case 4:marks="四";break;
        case 5:marks="五";break;
        case 6:marks="六";break;
        case 7:marks="日";break;
}
int sum=0,year;
for(year=1900;year<=2012;year++)
{
if(year%4==0&&year%100!=0||year%400==0)
{
sum+=366;
}
else
{
sum+=365;
}
     
}


for(int month=1;month<=2;month++)
{
if(month==2){
if(2013%4==0&&2013%100!=0||2013%400==0){
sum+=29;
}else{
sum+=28;
}
}else{
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12){
sum+=31;
}else{
sum+=30;
}
}
}
sum+=4;
week=sum%7;
       System.out.print("今天为星期"+week);
}
}