Convert Date Kotlin

Asked

Viewed 36 times

0

Next, I get a data json from an api:

"data": "2021-05-03T14:07:19.000Z"

need convert to show user... I made my data class with her: Data : Date

no Adapter called it with a function that goes back to the data class like this:

fun Date.formatte(): String =
    android.icu.text.SimpleDateFormat("dd/MM/yy - HH:mm ", Locale("pt-br", "America/Sao_Paulo"))
        .format(this)

at last it returns,the correct time and date but with 3 Hours less...what I am doing wrong?

  • Hello Gabriel, I think the date that comes in JSON is without GMT, and you are applying GMT in your conversion. That’s why the time difference.

  • Opa hasn’t worked yet!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.