Convert String to Joda LocalTime format (HH:mm:ss) and Remove milliseconds

DateTimeFormatter fmt = DateTimeFormat.forPattern("HH:mm:ss");
LocalTime localTime = fmt.parseLocalTime("02:51:20");
System.out.println("LocalTime:            "+localTime);

I need only 02:51:20 but it outputs as 02:51:20.000. Is there any way that I can remove the .000 (milliseconds) from the output.

Jon Skeet
people
quotationmark

Yes - you just need to format when you print out. Currently you're just using the default toString() representation. If you're happy with the formatter you've already got, you can just use:

System.out.println("LocalTime:            " + fmt.print(localTime));

people

See more on this question at Stackoverflow