2

I'm trying to parse date with folloing code:

let dateFormatter = ISO8601DateFormatter()
dateFormatter.timeZone = TimeZone(identifier: "UTC")
dateFormatter.formatOptions = [ .withInternetDateTime, .withFractionalSeconds ]

let date = dateFormatter.date(from: "2019-01-30T23:51:55.650144Z")
let string = dateFormatter.string(from: date) // 2019-01-30T23:51:55.650Z

Input date:

2019-01-30T23:51:55.650144Z

But output date is:

2019-01-30T23:51:55.650Z

This is keep only 3 digits in fractional part.

How to avoid it?

rmaddy
  • 314,917
  • 42
  • 532
  • 579

0 Answers0