Валидатор не принимает. Коллекция применена. В чем затык?
package com.javarush.task.task08.task0828;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.time.Month;
import java.util.ArrayList;
/*
Номер месяца
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader( new InputStreamReader( System.in ) );
ArrayList<Month> months = new ArrayList<>();
for (int i = 1; i <= 12; i++) {
months.add( Month.of( i ) );
}
System.out.print( "Input month name: " );
Month monthName = Month.valueOf( reader.readLine().toUpperCase() );
int monthNumber = months.indexOf( monthName );
System.out.printf( "%s%s is the %d month%n", monthName.toString().substring( 0, 1 ).toUpperCase( ), monthName.toString().substring( 1 ).toLowerCase( ), monthNumber+1 );
}
}