package pers.Lishuai.instrument;
import com.sun.org.apache.bcel.internal.generic.ARETURN;
/**
* @author: Lishuai
* @date: 2020-05-09 18:20
* @desc:
*/
public class MyDates {
int year;
int month;
int day;
//某年某月的天数有几天
public static int getDays(int year,int month) {
//判断输入的月份是否正确
if (month > 12 || month < 1) {
System.out.println("月份输入错误!!!");
return -1;
}else if (month == 2) {
if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)){
return 29;
} else {
return 28;
}
}else if (month == 4 || month == 6 || month == 9 || month == 11) {
return 30;
}else{
return 31;
}
}
//某一年是否是闰年
public static boolean isBleapYear(int year){
if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)){
return true;
} else {
return false;
}
}
}
是否闰年以及某年某月的天数查询
最新推荐文章于 2024-08-24 17:09:16 发布