j.doe
j.doe

Reputation: 23

How to convert format date from iso in kotlin

i'm still a beginner in android and kotlin.

I have a date 2020-04-05T22:38:16.295985+07:00

and expected value is 05 April 2020 22:38:16

How do that in kotlin ?

Upvotes: 1

Views: 772

Answers (1)

Yann Huissoud
Yann Huissoud

Reputation: 1023

From here

val actual = OffsetDateTime.parse("2020-04-05T22:38:16.295985+07:00", DateTimeFormatter.ISO_DATE_TIME)
val formatter = DateTimeFormatter.ofPattern("dd MMMM yyyy HH:mm:ss")
val formatDateTime = actual.format(formatter)

println(formatDateTime) //05 April 2020 22:38:16

Upvotes: 3

Related Questions