You are viewing a single comment's thread. Return to all comments →
Solution in Kotlin -
return if (s.lowercase().contains("pm")) { var time = s.replace("PM", "", ignoreCase = true).trim() val timeArray = time.split(":").toMutableList() val timeInt = timeArray[0].toInt() timeArray[0] = if (timeInt == 12) { "12" } else { (timeInt + 12).toString() } timeArray.joinToString(":") } else { var time = s.replace("AM", "", ignoreCase = true).trim() val timeArray = time.split(":").toMutableList() val timeInt = timeArray[0].toInt() timeArray[0] = if (timeInt == 12) { "00" } else { timeInt.toString().padStart(2, '0') } timeArray.joinToString(":") }
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 →
Solution in Kotlin -