Format LocalTime

0

I have a question when it comes to pairing my Local Time to String in order to import a csv file. The local time in the csv file is in the following format: "1:20:32" - > (hour, minute, second). Well, I've done the following:

 LocalTime duracion = LocalTime.parse(tipo, DateTimeFormatter.ofPattern("HH:mm:ss"));

And so the exception jumps me because logically it can not read the 0 in front.

My question is: How can I accept the time without the 0 in front? Since in my file all the local time fields come without 0 in front of the time when it only has one digit (0-9) that hour.

    
asked by Cristian Navarro Fernandez 31.05.2018 в 15:49
source

1 answer

2

Try changing to "H: mm: ss"

LocalTime duracion = LocalTime.parse(tipo, DateTimeFormatter.ofPattern("H:mm:ss"));
    
answered by 31.05.2018 / 15:53
source