【发布时间】:2017-06-10 09:38:55
【问题描述】:
我正在尝试解析这个
2017-01-23T10:12:31.484Z
使用 iOS 10 提供的原生 ISO8601DateFormatter 类,但总是失败。
如果字符串不包含毫秒,则Date 对象的创建没有问题。
我尝试过这个和许多options 组合,但总是失败...
let formatter = ISO8601DateFormatter()
formatter.timeZone = TimeZone(secondsFromGMT: 0)
formatter.formatOptions = [.withInternetDateTime, .withDashSeparatorInDate, .withColonSeparatorInTime, .withColonSeparatorInTimeZone, .withFullTime]
有什么想法吗? 谢谢!
【问题讨论】:
-
是的,我知道使用
dateFormat是一种方式,但我想使用iOS 10的原生类... :(
标签: ios swift date swift3 ios10