https://grokonez.com/kotlin/kotlin-get-current-datetime

Kotlin – Get Current Date/Time

In the tutorial, grokonez will show you how to get current Date/Time by LocalDateTime, LocalDate, LocalTime & ZonedDateTime of java.time package with Kotlin language.

I. Kotlin - Get Current Date/Time

1. Use LocalDateTime

If we want to get both current date & time, we use LocalDateTime:

import java.time.LocalDateTime
...

val currentDateTime = LocalDateTime.now()

// default format is DateTimeFormatter.ISO_DATE_TIME
println(currentDateTime)
/*
	2018-01-25T13:46:52.125
*/

How to format it? -> We can use DateTimeFormatter

1.1 Formatted by Defined Constants of DateTimeFormatter

More at:

https://grokonez.com/kotlin/kotlin-get-current-datetime

#kotlin #date #time

Kotlin - Get Current Date/Time » grokonez
1.40 GEEK