Apache DateUtils not able to parse 2018-03-11 02:00:00 Daylight saving timestamp

521 views Asked by At
public static void main(String[] args){
        Date date = null;
        try {
            date = DateUtils.parseDateStrictly("2018-03-11 01:59:00", "yyyy-MM-dd HH:mm:ss");
            System.out.println(date.getTime());
            date = DateUtils.parseDateStrictly("2018-03-11 02:00:00", "yyyy-MM-dd HH:mm:ss");
            System.out.println(date.getTime());
        }catch(Exception e) {
            e.printStackTrace();
        }
    }

The first timestamp gets parsed successfully however the second timestamp fails to parse. Is there a bug with org.apache.commons.lang3.time.DateUtils? I am using commons-lang3-3.4.jar

1520751540000
java.text.ParseException: Unable to parse the date: 2018-03-11 02:00:00 at org.apache.commons.lang3.time.DateUtils.parseDateWithLeniency(DateUtils.java:401) at org.apache.commons.lang3.time.DateUtils.parseDateStrictly(DateUtils.java:343) at org.apache.commons.lang3.time.DateUtils.parseDateStrictly(DateUtils.java:321) at com.ecw.vocabulary.mapper.impl.Test.testMetoo(Test.java:59) at com.ecw.vocabulary.mapper.impl.Test.main(Test.java:40)

1

There are 1 answers

0
DavidZ On BEST ANSWER

Because it doesn't exist!

Sunday, March 11, 2018, 2:00:00 am clocks were turned forward 1 hour to Sunday, March 11, 2018, 3:00:00 am local daylight time instead.