Questions about the java. Text.SimpleDateFormat class setLenient (false)

the code is as follows

public static void main(String[] args) {
        String text = "2018-11-26-13:50:00";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-hh:mm:ss");
        sdf.setLenient(false);
        try {
            System.out.println(sdf.parse(text));
        } catch (ParseException e) {
            //  java.text.ParseException: Unparseable date: "2018-11-26-13:50:00"
            e.printStackTrace();
        }
    }

setLenient (false), the date midhour is operational from 1 a.m. to 12:00, and an error is reported between 13:00 and 00:00
ask the great god to solve the doubt.

Feb.27,2021
The

setLenient method is to set whether a given format can be handled with tolerance in the event of an error.
when the value is set to false, the given string is not tolerated. In this case, hh represents a 12-hour base time, and only 12 hours are available. Change it to HH, to indicate a 24-hour base time.

Menu