Ich habe ein seltsames Problem, wenn eine Zeichenfolge in eine LocalParse String Local
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class Main {
public static void main(String args[])
{
DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_TIME;
LocalDateTime.parse("00:00",formatter);
}
}
Gib mir analysieren:
Exception in thread "main" java.time.format.DateTimeParseException: Text '00:00' could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: {},ISO resolved to 00:00 of type java.time.format.Parsed
at java.time.format.DateTimeFormatter.createError(Unknown Source)
at java.time.format.DateTimeFormatter.parse(Unknown Source)
at java.time.LocalDateTime.parse(Unknown Source)
at Main.main(Main.java:9)
Caused by: java.time.DateTimeException: Unable to obtain LocalDateTime from TemporalAccessor: {},ISO resolved to 00:00 of type java.time.format.Parsed
at java.time.LocalDateTime.from(Unknown Source)
at java.time.format.Parsed.query(Unknown Source)
... 3 more
Caused by: java.time.DateTimeException: Unable to obtain LocalDate from TemporalAccessor: {},ISO resolved to 00:00 of type java.time.format.Parsed
at java.time.LocalDate.from(Unknown Source)
... 5 more
Ich möchte einen String mit Format analysieren "Stunde: Minuten" zu eine lokale Zeit (24H Format). Es ist mir egal, welcher Monat/Jahr/Tag wie vereinbart ist, ich will nur die Zeit.
Scheint, dass Ihre Daten "00:00" nicht mit dem von ISO_LOCAL_TIME vorgegebenen Format kompatibel sind. – user1929959