You are viewing a single comment's thread. Return to all comments →
Here's my solution in Java:
public static String timeConversion(String s) { String meridiem = s.substring(8); int hours = Integer.parseInt(s.substring(0, 2)); String colonsMinutesAndSeconds = s.substring(2, 8); if (meridiem.equals("AM") && hours == 12) { hours = 0; } else if (meridiem.equals("PM") && hours != 12) { hours += 12; } return String.format("%02d%s", hours, colonsMinutesAndSeconds); }
Seems like cookies are disabled on this browser, please enable them to open this website
Time Conversion
You are viewing a single comment's thread. Return to all comments →
Here's my solution in Java: