You are viewing a single comment's thread. Return to all comments →
my java solution: ` s= s.trim(); String timeMarker=s.substring(8); String originalTime = s.substring(0, 8); String[] originalTimeList= originalTime.split(":"); String hour = originalTimeList[0]; Integer hourInt = Integer.parseInt(hour); StringBuilder newTime = new StringBuilder();
if(timeMarker.equals("PM")){ if(hourInt!=12){ hourInt+=12; hour= String.valueOf(hourInt); } } else{ if(hourInt==12){ hour= "00"; } } return newTime.append(String.valueOf(hour)).append(":") .append(originalTimeList[1]).append(":") .append(originalTimeList[2]).toString();
`
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 →
my java solution: ` s= s.trim(); String timeMarker=s.substring(8); String originalTime = s.substring(0, 8); String[] originalTimeList= originalTime.split(":"); String hour = originalTimeList[0]; Integer hourInt = Integer.parseInt(hour); StringBuilder newTime = new StringBuilder();
`