I
I
ilitaexperta2019-02-01 15:15:22
Working with date/time
ilitaexperta, 2019-02-01 15:15:22

How to deal with ISO8601 Date and microseconds in Swift?

There is a service that gives dates in ISO8601 format with fractional seconds:
2019-01-30T23:51:55.650144Z
The standard ISO8601DateFormatter in Swift cuts microseconds to three decimal places:
2019-01-30T23:51:55.650Z
Which creates problems. For example, in the same android Instant quite normally stores and parses such a format. Is there any workaround? Maybe an analogue of the Date class, with higher precision?
I found only this solution https://stackoverflow.com/questions/43123944/how-t... but it is invalid. It doesn't always parse correctly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
iMaximus, 2019-02-01
@iMaximus

If you have IOS 10 and older and swift 4 use ISO8601DateFormatter. For earlier versions, you need a tambourine, but it can also be solved.
https://stackoverflow.com/questions/28016578/how-t...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question