import java.util.Calendar;
import java.util.Scanner;
/**
* 需求:键盘录入任意一个年份,获取任意一年的二月有多少天
*
*/
public class Test7 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("请输入一个年份:");
int year=sc.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));
}
}
|
|