Im working on a To-Do list program.
I want to make it for the user possible to input a date, time and regarding. I already have the date. What Im missing is the time.
DateTimeFormatter formateTime = DateTimeFormatter.ofPattern("HH:mm");
LocalDate timeNotFormated = null;
String time = "22:22"; //* here is the user input for example 22:22
timeNotFormated = LocalDate.parse(time, formateTime);
System.out.println(timeNotFormated);
But I get many exceptions. Is there something Im missing something?
Exception observed:
Exception in thread "main" java.time.format.DateTimeParseException: Text '22:22' could not be parsed: Unable to obtain LocalDate from TemporalAccessor: {},ISO resolved to 22:22 of type java.time.format.Parsed
The exception happens in the following line:
timeNotFormated = LocalDate.parse(time, formateTime);