Java LocalTime Password Exclusions

I had a code snippet that worked perfectly and now somehow does not work.

I am reading a csv file and getting an error when reading in a 4:38 format time field.

My code that throws an exception:

 LocalTime.parse("4:38", DateTimeFormatter.ofPattern("HH:mm")) 

I also tried "H:mm" or "H:m" for the template, but it throws the same exception: Text '4:38' could not be parsed at index 0 . Any idea why this throws an exception on the watch number?

I am using Java 8.

+5
source share
2 answers

The pattern requires one "H" and one "m".

 LocalTime.parse("4:38", DateTimeFormatter.ofPattern("H:m")); 

It works great for 4:38 and 14:38.

White paper : see "Formatting and Analysis Templates"

+9
source

"H: mm" works great for me. enter image description here enter image description here

0
source

All Articles