I'm converting 12-hour style time to 24-hour. The problem is that when seconds are "00" they are not printed in spite of the formatter pattern. Why is this happening and how to print zero seconds?
public static void main(String[] args) {
String time_1 = "07:05:40PM";
String time_2 = "07:05:00PM";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("hh:mm:ssa");
System.out.println("time_1 " + LocalTime.parse(time_1, formatter));
System.out.println("time_2 " + LocalTime.parse(time_2, formatter));
}
The output is:
time_1 19:05:40
time_2 19:05