The Date
type is a Codable
type in Swift. However, dates are not straightforward to decode, like other types conforming to the Codable
protocol, because the default format used by JSONDecoder
is not standard in JSON.
Dates can be encoded using different formats in JSON data. To handle all these formats, the JSONDecoder class has a dateDecodingStrategy
property, which can be configured with several decoding strategies according to the date format you must decode.