package com.hui2_kehou;
import java.util.Calendar;
import java.util.Scanner;
public class Demo_Calendar {
public static void main(String[] args) {
//Calendar instance = Calendar.getInstance();
System.out.println("请输入年份");
int year= new Scanner(System.in).nextInt();
Calendar cal = Calendar.getInstance();
cal.set(year, 2, 1);
cal.add(Calendar.DAY_OF_MONTH, -1);
System.out.println(cal.get(Calendar.DAY_OF_MONTH));
if(cal.get(Calendar.DAY_OF_MONTH)==29){
System.out.println("是闰年");
}else{
System.out.println("不是闰年");
}
}
}
|
|