Home » Java » Java String to Date Parse-Exceptionshub

Java String to Date Parse-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

I am trying convert String to Date but getting this error.

java.text.ParseException: Unparseable date: "Wed Feb 16 20:04:17 EET 2022"
at java.text.DateFormat.parse(DateFormat.java:366)
at com.mycompany.facebookproject.OpenFace.main(OpenFace.java:55)

My code is:

String val= "Wed Feb 16 20:04:19 EET 2022";
expiry=new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy").parse(val);
How to&Answers:

I guess its a typo:

String dateSt= "Wed Feb 16 20:04:19 EET 2022";
        Date parse = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy").parse(dateSt);
        System.out.println(parse);