How to get Current date and time in Kotlin android

Ansar Ali
Jan 13, 2021

--

To know the current date and time

  1. create a variable to store the format of date and time
val simpleDateFormat= SimpleDateFormat("dd-MM-yyyy HH:MM:SS")

2.After that we have to call the Date function, who can provide us date and time in a variable

val currentDT: String = simpleDateFormat.format(Date())

3. Last use Variable currentDT where you want

I hope it will use full

Thank you :)

--

--

Ansar Ali
Ansar Ali

Written by Ansar Ali

Flutter and Android app developer.

No responses yet