I want to parse this value "AuthDate": "2021-08-17T19:03:27+04:00" like 17/08/21, 19:03:27
I tried this var formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd, HH:MM:SS") but its not working
I want to parse this value "AuthDate": "2021-08-17T19:03:27+04:00" like 17/08/21, 19:03:27
I tried this var formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd, HH:MM:SS") but its not working
Firstly, you would need to parse the string that you've got into an object that kotlin can use, and then, you can use that object to format it to whichever format suits you :
fun main() {
val string = "2021-08-17T19:03:27+04:00"
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssz")
val parsedDate = formatter.parse(string)
val displayFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd, HH:MM:SS")
val result = displayFormatter.format(parsedDate)
println(result)
}