How do you interpret dates with NSDateFormatter?

前端 未结 1 1548
春和景丽
春和景丽 2020-12-20 08:24

In the Apple Docs, they say that NSDateFormatter uses the Unicode for spec. I\'ve read the spec, but I\'m having troubles interpreting this date:

NSDateForm         


        
相关标签:
1条回答
  • 2020-12-20 08:49

    Sorry folks, figured it out already. NSDateFormatter defaults to using the current system locale. In the code example above, it only fails if you set your system locale to something other than U.S. To fix it, just before to set the locale to the one used by your date string, like this:

    [frm setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease]];
    
    0 讨论(0)
提交回复
热议问题