date - Java 8 - Trying to convert String to LocalDateTime -
this question has answer here:
- java string date conversion 13 answers
i trying convert below string
localdatetime
, somehow 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 problem in pattern.
you have problem pattern, should use 'h' hours(0-23). type formatter , datetime wrong. 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);
Comments
Post a Comment