Conversion of string to LocalDateTime in Java 8 -
how convert string "23:00" localdatetime in java 8? doesn't seems working,
localdatetime datetime1 = localdatetime.parse("23:00", datetimeformatter.ofpattern("hh:mm"));
this exception thrown,
java.time.datetimeexception: unable obtain localdatetime temporalaccessor: {},iso resolved 23:00 of type java.time.format.parsed
you pass time information parser, , needs create localdatetime. parser can't guess date part want locatedatetime.
use
localdatetime time = localtime.parse("23:00", datetimeformatter.ofpattern("hh:mm")) .atdate(localdate.now());
for example, if want today @ 23:00.
Comments
Post a Comment