Answers for "how to calculate time in kotlin"

1

kotlin get time milis hour minutes

fun getTimeWithMilis(millis: Long): String {
        val date = Date(millis)

        val formatter = SimpleDateFormat("HH:mm")
        formatter.timeZone = TimeZone.getTimeZone("UTC")

        val formatted = formatter.format(date)
        Log.d("Time : ",formatted)
        return formatted.toString();

    }
Posted by: Guest on October-21-2021
0

get the time remaning for a date kotlin

val diff: Long = date1.getTime() - date2.getTime()
val seconds = diff / 1000
val minutes = seconds / 60
val hours = minutes / 60
val days = hours / 24
Posted by: Guest on September-26-2020

Code answers related to "how to calculate time in kotlin"

Browse Popular Code Answers by Language