Find the number of days in a month

The problem

Write a program that prompts the user to enter the month and year and displays the number of days in the month. For example, if the user entered month 2 and year 2012, the program should display that February 2012 had 29 days. If the user entered month 3 and year 2015, the program should display that March 2015 had 31 days.

Breaking it down

public static void main(String[] strings) {

    Scanner input = new Scanner(System.in);

    System.out.print("Enter a month number: ");
    int month = input.nextInt();

    System.out.print("Enter a year: ");
    int year = input.nextInt();

    input.close();

    LocalDate date = LocalDate.of(year, Month.of(month), 01);
    int length = date.getMonth().length(false);

    System.out.print(Month.of(month).getDisplayName(TextStyle.FULL,
            Locale.US)
            + " " + year + " has " + length + " days");
}

Output

Enter a month number: 2
Enter a year: 2016
February 2016 has 28 days