android kotlin
Updated Wed, 06 Jul 2022 05:19:01 GMT

How to get current time from device in kotlin?

How can I get the current time from device? I need possibly ways in kotlin language.


Here simple way to get the time!

val c = Calendar.getInstance()
val year = c.get(Calendar.YEAR)
val month = c.get(Calendar.MONTH)
val day = c.get(Calendar.DAY_OF_MONTH)
val hour = c.get(Calendar.HOUR_OF_DAY)
val minute = c.get(Calendar.MINUTE)