Avatar ·

How to get current local date and time in Kotlin?

Hello everyone! I just started learning Kotlin for Android development and encountered a seemingly simple task: I need to get the current date and time to display them to the user in the format "dd.MM.yyyy HH:mm". But I'm confused about how to do it correctly. I tried using `Date()` and `SimpleDateFormat`, like in Java, but in Kotlin it looks cumbersome. Plus, I heard that `java.util.Date` is considered deprecated, and there is something new. Here is my current code, which works, but I'm sure this is not the best way: ```kotlin import java.text.SimpleDateFormat import java.util.Date import java.util.Locale fun getCurrentDateTime(): String { val dateFormat = SimpleDateFormat("dd.MM.yyyy HH:mm", Locale.getDefault()) val date = Date() return dateFormat.format(d