You are viewing a single comment's thread. Return to all comments →
Kotlin Solution
fun timeConversion(s: String): String { val splitString = s.split(":").toMutableList() val obtainFormat = splitString.last().takeLast(2) val hour = splitString.first().toInt() if(obtainFormat == "AM"){ splitString[0] = String.format("%02d",hour.toInt() % 12) } else { splitString[0] = String.format("%02d",if(hour < 12) hour + 12 else hour) } return splitString.joinToString(":").dropLast(2) }
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 →
Kotlin Solution