Reputation: 153
Hello everyone i am just learning android and i got this case when i have the data with content of
2021-05-16T05:02:26Z
which have this format yyyy-MM-dd'T'HH:mm:ss
How can i convert it to Sunday-May-2021 05:02
?
I've tried googling and exploring the web but most of them only convert yyyy-MM-dd'T'HH:mm:ss to dd-mm-yyyy and any other format, haven't found one that convert it to human readable.
Thanks in advance.
Upvotes: 1
Views: 2569
Reputation: 754
Check out DateTimeFormatter patterns. In your case it would look like this:
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter
val zonedTime = ZonedDateTime.parse("2021-05-16T05:02:26Z")
val formatted : String = zonedTime.format(DateTimeFormatter.ofPattern("EEEE-MMMM-u HH:mm"))
Upvotes: 5