How can I create an instance of java.util.Date
out of a custom date time string?
This is what I tried so far:
Given I have the this custom date time string:
Fri Jul 29 12:56:35 UTC 2022
Using Joda-Time in the following piece of code:
String time = "Fri Jul 29 12:56:35 UTC 2022";
DateTimeFormatter df = DateTimeFormat.forPattern("EEE MMM dd HH:mm:ss z yyyy");
long millis = df.parseMillis(time);
I get the following exception:
java.lang.IllegalArgumentException: Invalid format: "Fri Jul 29 12:56:35 UTC 2022" is malformed at " UTC 2022"
at org.joda.time.format.DateTimeFormatter.parseMillis(DateTimeFormatter.java:644)