// for example, february of 2000
YearMonth.of(2000, 2).lengthOfMonth();
import java.util.*;
import java.time.YearMonth;
public class GetNumberOfDaysInMonthJava {
public static void main(String[] args) {
// Get number of days in given month of the year
int year,month;
Scanner input = new Scanner(System.in);
year = input.nextInt();
month = input.nextInt();
int numberOfDaysInMonth1 = getNumberOfDaysInMonth(year, month);
System.out.println("Number of days in Feb 2019: "+numberOfDaysInMonth1);
int numberOfDaysInMonth2 = getNumberOfDaysInMonth(2020, 2);
System.out.println("Number of days in Feb 2020: "+numberOfDaysInMonth2);
}
// Method to get number of days in month
public static int getNumberOfDaysInMonth(int year,int month)
{
YearMonth yearMonthObject = YearMonth.of(year, month);
int daysInMonth = yearMonthObject.lengthOfMonth();
return daysInMonth;
}
}