You are viewing a single comment's thread. Return to all comments →
Java Solution
public static String timeConversion(String s) { boolean isAM = false; if (s.endsWith("AM")) { isAM = true; } s = s.substring(0, s.length() - 2); int hour = Integer.valueOf(s.substring(0,2)); if (isAM && hour == 12) { return "00".concat(s.substring(2)); } else if (!isAM && hour != 12) { return Integer.toString(hour + 12).concat(s.substring(2)); } else { return s; } }
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 →
Java Solution