We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
publicstaticStringtimeConversion(Strings){// Write your code hereString[]time=s.split(":");inthour=Integer.valueOf(time[0])+12;if(time[2].contains("PM")){time[0]=String.valueOf(hour==24?hour-12:hour);}else{time[0]=time[0].contains("12")?"00":time[0];}returntime[0]+":"+time[1]+":"+time[2].substring(0,2);}
Cookie support is required to access HackerRank
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 solution in Java: