0

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 ?

j.doe
  • 13
  • 5
  • Does this answer your question? [How to convert LocalDateTime object into ISO string including time zone?](https://stackoverflow.com/questions/41656756/how-to-convert-localdatetime-object-into-iso-string-including-time-zone) – MMG Apr 06 '20 at 03:26
  • Does this answer your question? [Converting ISO 8601-compliant String to java.util.Date](https://stackoverflow.com/questions/2201925/converting-iso-8601-compliant-string-to-java-util-date) (not that you should want to convert to `java.util.Date`, that class is poorly designed and long outdated; but some of the answers offer other and better solutions). – Ole V.V. Apr 06 '20 at 08:04

1 Answers1

3

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
aiqency
  • 1,015
  • 1
  • 8
  • 22