+ 4

Code Trainer (Military Time)

I need help to find what I'm missing to solve the problem. Don't give me the solution please. Problem: You want to convert the time from a 12 hour clock to a 24 hour clock. If you are given the time on a 12 hour clock, you should output the time as it would appear on a 24 hour clock. Task: Determine if the time you are given is AM or PM, then convert that value to the way that it would appear on a 24 hour clock. Input Format: A string that includes the time, then a space and the indicator for AM or PM. Output Format: A string that includes the time in a 24 hour format (XX:XX) Sample Input: 1:15 PM Sample Output: 13:15 My code: https://code.sololearn.com/cCLs9DHjeQBJ/?ref=app

13th Mar 2021, 7:09 PM
Valeria
Valeria - avatar
5 ответов
+ 2
Spentify hi! It fails two tests, but doesn't show me the output
13th Mar 2021, 7:18 PM
Valeria
Valeria - avatar
+ 2
Spentify yes, that was. I spent days looking for the solution. I appreciate it a lot, thank you
13th Mar 2021, 7:30 PM
Valeria
Valeria - avatar
+ 2
Maybe you should use the tools for working with time included in the JDK (Java 8), such as java.time.LocalTime and java. time.format.DateTimeFormatter? Everything is beautifully described in 2-3 lines... Му сode: https://code.sololearn.com/chh3tNwVuRVy/?ref=app
6th Aug 2021, 7:29 AM
IMPERATOR_IGOR_I