How to get current Date (day month and year) and time (hours, minutes and seconds) in local time in Kotlin?
I tried going through LocalDateTime.now()
but it gives me an error saying that Call requires API Level 26 (current min is 21).
Solution
val sdf = SimpleDateFormat("dd/M/yyyy hh:mm:ss")
val currentDate = sdf.format(Date())
System.out.println(" C DATE is "+currentDate)
Or use this way
import java.util.Calendar ; import java.util.Date ; Date currentTime = Calendar . getInstance (). getTime ();