Reputation: 81
We are using a back-end server built with ASP.NET Core 2.1, which is returning DateTime using ISO 8601 to the clients Web / Android / iOS.
The problem is that the back-end is formatting date and time using a variable fraction of seconds, which both Android and iOS does not expect from their fixed yyyy-MM-ddThh:mm:ss.SSSZ format.
Now, we know that from iOS 11 there is a proper ISO 8601 deserializer, but we cannot move from iOS 9; for Android we did not found a solution yet.
We are struggled if we need to implement a custom DateTime formatter on back-end and deliver a fixed datetime format and potentially break the standard (we would like to serialize DateTimeOffset too for timezones management) or find a solution on client side.
W3C clearly says that a variable fraction of seconds needs to be supported to being ISO 8601 compatible: https://www.w3.org/TR/NOTE-datetime
What would be the best future-proof solution?
Upvotes: 1
Views: 1334
Reputation: 27
Try something like this
val format = SimpleDateFormat("yyyy-MM-ddThh:mm:ss.SSSZ")
textView.text = format.format(date)
Upvotes: 2