import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.time.format.ResolverStyle;
import java.util.Locale;

class Main {
    public static void main(String[] args) {
        DateTimeFormatter parser = DateTimeFormatter.ofPattern("MM/dd/uuuu", Locale.ENGLISH)
                .withResolverStyle(ResolverStyle.STRICT);
        String arr[] = {
                "12/31/2022", // Will be parsed normally
                "02/31/2022" // Will fail against ResolverStyle.STRICT check
        };
        for (String s : arr) {
            try {
                System.out.println("===========================");
                System.out.println("Trying to parse " + s + " using the format MM/dd/uuuu");
                System.out.println("Parsed to " + LocalDate.parse(s, parser));
            } catch (DateTimeParseException e) {
                System.out.println(e.getMessage());
                // throw e;
            }
        }
    }
}