2015-09-29 163 views
2

我写了下面的代码将时间从12小时格式转换为24小时格式。它可以在模拟器上正常工作,但在使用设备时它会返回null。从12小时格式到24小时格式的时间转换

​​
+0

在这里什么反应u得到 - >结束时间从服务器性反应: –

+0

我得到的时间在12小时格式,如10:00 PM – rajesh

+0

我们这么认为。你能显示确切的字符串吗? –

回答

1

尝试在您NSDateFormatter设置本地化:

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 
NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]; 
[dateFormatter setLocale:locale]; 
+0

我试过这个但同样的问题 – rajesh

+0

你的设备上的时区是什么? – Abhinav

+0

这对我来说就像魅力一样。您可以尝试重置您的设备,或尝试使用其他设备吗? – Abhinav

0

喜的朋友,

 Issue is with the device settings ,to resolve this issue i changed my device time format as "automatic" ,now its working fine with those settings change. 
相关问题