Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SimpleDateFormat with pattern yyyyMMddhhmmss unable to parse date "20160327020727"

I am getting an exception when parsing date 20160327020727 with format yyyyMMddhhmmss. Note that the lenient is set to false.

    SimpleDateFormat df = new SimpleDateFormat("yyyyMMddhhmmss");
    df.setLenient(false);
    try {
        Date dt = df.parse("20160327020727");
    } catch (ParseException e) {
        e.printStackTrace();
    }

It is parsing other dates with the same format and it is working as expected. Why is this happening?

like image 376
Amer Hukic Avatar asked Feb 06 '23 08:02

Amer Hukic


1 Answers

CET changes to summer time the last Sunday of march, so there is no 2AM this day.

You go from 1:59 to 3:00

like image 157
Akah Avatar answered Feb 11 '23 16:02

Akah