Using LocalTime in Java 8, LocalTime has many useful methods like getHour()
or the getMinute()
method,
For example,
LocalTime intime = LocalTime.parse(inputString, DateTimeFormatter.ofPattern("h:m a"));
String outtime = intime.format(DateTimeFormatter.ISO_LOCAL_TIME);
In some cases, First line alone can do the required parsing