0
Military time (couch code)
How could I solve that problem without switch case statement? https://code.sololearn.com/c11zHomIUBHz/?ref=app
2 Antworten
+ 2
Take a look at the classes:
*java.time.LocalTime *java.time.format.DateTimeFormatter
+ 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..