I have a piece of code written to parse date string - 

```
    DateFormat cal = new SimpleDateFormat("yyyy-MM-dd hh:mm");
    cal.setLenient(false);
    try {
        cal.parse("2018-01-01 14:42");
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
}

```

But I get an exception saying - 

```
java.text.ParseException: Unparseable date: "2018-01-01 14:42"
at java.base/java.text.DateFormat.parse(DateFormat.java:388)
at MyClass.main(MyClass.java:10)

```

I am not sure why I am seeing this error as the date string and the format given is right. Please help