Parsing ISO 8601 with NSDateFormatter

痞子三分冷 提交于 2019-11-29 12:48:56

Three things:

  • Use the -[NSDateFormatter getObjectValue:forString:range:error:] method to learn how much of the string was parsed and what error prevented parsing further.

  • The ZZZZ format string corresponds to something like "GMT+02:00", with that "GMT" in there. You may need to inject that into the string you're parsing for it to work.

  • Apple's Data Formatting Guide advises "Consider Unix Functions for Fixed-Format, Unlocalized Dates".

Now the dedicated NSISO8601DateFormatter is available.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!