The simplest way would probably be to parse it to a LocalTime
:
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("hh:mm:ssa");
LocalTime time = LocalTime.parse("10:20:05PM", fmt);
System.out.println("time = " + time); //22:20:05
Note: the a
in the format is for AM/PM.