I am trying to convert the below String to LocalDateTime, but somehow its not working.
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss.SSS");
val dateTime = LocalDateTime.parse("2016-09-21 13:43:27.000", formatter);
It seems there is a problem in Pattern.
You have a problem with your pattern. You should use 'H' for hours (0-23). The type for formatter and dateTime is wrong.
This would work correctly:
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
LocalDateTime dateTime = LocalDateTime.parse("2016-09-21 13:43:27.000", formatter);
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