socket.io-client-swift icon indicating copy to clipboard operation
socket.io-client-swift copied to clipboard

Date format was changed to timestamp?

Open flyinghawker opened this issue 3 years ago • 1 comments

From java backend, certain field is Date but I got timestamp in iOS, which affects negatively my work of checking signature. e.g. server: ..."createdAt":"2021-04-26T18:43:30.901Z"...

socket.on("message") { data, ack in... ..."createdAt":1619433810901...

when I try to parse the string with JSONDecoder, as well as config it as such

            let dateFormatter = DateFormatter()
            dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
            jsonDecoder.dateDecodingStrategy = .formatted(dateFormatter)

I got error blabla like: "expected String but found number"...

For now, I have to manually convert it back to date and do parse work, this looks like stupid step but inevitable. Is there any way to avoid this or just accept it. Thanks

flyinghawker avatar Apr 26 '21 10:04 flyinghawker

I have exactly the same issue. Did you find a solution ?

iKK001 avatar Dec 01 '21 11:12 iKK001