您的位置:首页 > 其它

计算年度第几天

2016-09-19 11:21 120 查看
/**
* 输入某年某月某日,判断这一天是这一年的第几天
*/
public int day(int year,int month,int day){
int date = 0;
int arr[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
if ((year % 400 == 0) || (year % 4 == 0 && year % 100 != 0)) {//闰年
arr[1] = 29;
}
for (int i = 0; i < month - 1; i++) {
date += arr[i];
}
date += day;
return date;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: