2015-09-29 162 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. 
相關問題