Java利用Calendar类获取每年的二月份有多少天

Java利用Calendar类获取每年的二月份有多少天

`package time;

import java.util.Calendar;
import java.util.Scanner;

public class eryuetian {
public static void main(String[] args) {
	Scanner in = new Scanner(System.in);
	System.out.println("请输入年份:");
	int year = in.nextInt();
	Calendar calendar = Calendar.getInstance();
	calendar.set(year, 2, 1);
    calendar.add(Calendar.DAY_OF_MONTH, -1);
	System.out.println( calendar.get(Calendar.DAY_OF_MONTH));
}
}

`

你可能感兴趣的:(java,java,eclipse)