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.
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));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With