NSDateFormatter变空 [英] NSDateFormatter getting Null

查看:95
本文介绍了NSDateFormatter变空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我得到一个字符串,并将该字符串传递给dateFormatter,但我得到的是nil,而不是 IST ,我得到的是 PDT 我可能会使用其他格式,

I in my project I am getting a string I am passing the string to the dateFormatter but I am getting nil, in the string instead of IST I may get PDT I may get any other formats,

NSString* currentDateString = @"2012-11-09 12:31:53.0 **IST**";

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.S z"];

NSDate *dateFromString = [dateFormatter dateFromString:currentDateString];

推荐答案

如果仅在iOS 6.0+设备/模拟器上进行测试,请在iOS 6.0设备以下进行测试.我认为在Ios 6.0+中,与缩写有关的某些内容已更改. iOS 6.0+中的缩略词典包含的值与低于6.0的iOS中包含的值不同.

If you are testing on iOS 6.0+ device/simulator only, test it on below iOS 6.0 device. I think in Ios 6.0+ something is changed related to abbreviations. Abbreviations dictionary in iOS 6.0+ contains different values than in iOS below 6.0.

这篇关于NSDateFormatter变空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆