Military time (couch code)

How could I solve that problem without switch case statement? https://code.sololearn.com/c11zHomIUBHz/?ref=app

11th Mar 2020, 5:48 AM
Keyz - avatar
2 Answers
+ 2
Take a look at the classes: *java.time.LocalTime *java.time.format.DateTimeFormatter
11th Mar 2020, 6:29 AM
Mihai Apostol
Mihai Apostol - avatar
+ 1
You can use split method By splitting input with :, and then space, You get 3 values hour, seconds, AM or PM. Then you need just change hour depending on AM or PM, by adding 12, or append 0 when necessary... By the way, your program giving wrong for 12:00 PM, as 00:00 but it should me same as 12:00 only..
11th Mar 2020, 3:42 PM
Jayakrishna 🇮🇳