I can't seem to get my date with variable whitespace to parse.
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("EEE MMM d HH:mm:ss yyyy");
LocalDateTime dateTime = LocalDateTime.parse(date, formatter);
This is the format I have to accept
Sat Jul 2 08:52:13 2016
Sat Jul 12 08:52:13 2016
I can get the top to pass if I change my formatter to the below, but it will break with a 2 digit number
EEE MMM d HH:mm:ss yyyy
You can try pattern of "EEE MMM ppd HH:mm:ss yyyy" for your format.
ppd
outputs the day padded on the left with spaces to a width of 2.
See Pad modifier in DateTimeFormatter for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With