Get Current Time In Kotlin

[Solved] Get Current Time In Kotlin | Kotlin - Code Explorer | yomemimo.com
Question : get current time in kotlin

Answered by : dizzy-dunlin-4ny5x256jt49

// declaration
var c : Calendar = Calendar.getInstance()
private var df : SimpleDateFormat? = null
private var formattedDate = ""
// goes to main method or onCreate(Android)
df = SimpleDateFormat("dd-MM-yyyy HH:mm a")
formattedDate = df!!.format(c.time)
println("Format dateTime => $formattedDate")

Source : | Last Update : Sat, 02 Apr 22

Answers related to get current time in kotlin

Code Explorer Popular Question For Kotlin