You are viewing a single comment's thread. Return to all comments →
Any tips for coming up with simpler solutions? I keep coming up with complicated solutions. my solution to this problem was:
String amOrPm = parts[parts.length - 2]; if(amOrPm.equals("A")){ if(parts[0].equals("1") && parts[1].equals("2")) return s.replaceFirst("12", "00").substring(0, parts.length - 2); else return s.substring(0, parts.length - 2); } else if(amOrPm.equals("P")) { if(parts[0].equals("1") && parts[1].equals("2")) return s.substring(0, parts.length - 2); else return s.replaceFirst((s.substring(0,2)), (Integer.parseInt(s.substring(0,2)) + 12) + "").substring(0, parts.length - 2); } 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 →
Any tips for coming up with simpler solutions? I keep coming up with complicated solutions. my solution to this problem was: