You are viewing a single comment's thread. Return to all comments →
What do you think about this solution?
public static String timeConversion(String s) { String[] ss = s.split(":"); String res = ""; if(ss[0].equals("12") && ss[ss.length-1].contains("AM")) { res = "00:" + ss[1] + ":" + ss[ss.length-1].substring(0, 2); } else if(Integer.parseInt(ss[0]) > 0 && Integer.parseInt(ss[0]) < 12) { if(ss[ss.length-1].contains("AM")) { res = s.substring(0, s.length() - 2); } else if(ss[ss.length-1].contains("PM")) { res = (Integer.parseInt(ss[0]) + 12) + ":" + ss[1] + ":" + ss [ss.length-1].substring(0, 2); } } else { res = s.substring(0, s.length() - 2); } return res; } }
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 →
What do you think about this solution?