You are viewing a single comment's thread. Return to all comments →
public static String timeConversion(String s) { // Write your code here String [] strArray = s.split(":"); String hour = strArray[0]; String answer = ""; Integer hourPM = Integer.parseInt(hour); if (s.contains("AM")){ if(hour.equalsIgnoreCase("12")){ hour = "00"; } answer = hour +":"+ strArray[1] +":"+ strArray[2].substring(0,2); }else if(s.contains("PM")){ if (hourPM < 12){ hourPM = hourPM + 12; } answer = hourPM +":"+ strArray[1] +":"+ strArray[2].substring(0,2); } return answer; }
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 →