I am trying to parse a string of the format "Thu May 07 00:00:00 CEST 2020" to a java.util.Date. I use the suggested approaches with SimpleDateFormat. However, all the formats I've tried lead to "java.text.ParseException: Unparseable date".
My code looks like this:
fun String.toDate(format: String = "EEE MMM dd HH:mm:ss z yyyy"): Date = SimpleDateFormat(format).parse(this)
I've tried formats such as
- "EEE MMM dd HH:mm:ss z yyyy"
- "EEE MMM dd HH:mm:ss zzzz yyyy"
- "EEE MMM d HH:mm:ss z yyyy"
- "EEE MMM d HH:mm:ss zzzz yyyy"
All of them lead to the same exception. What am I missing?