Cha*_*lis 4 iso objective-c nsdate
我需要从json创建一个NSDate,并以我从未使用过的格式创建日期.我要回来的日期字符串是2014-02-07T03:10:43.824Z.有谁知道我需要用于日期格式化程序的正确日期格式字符串?
Val*_*din 12
NSDateFormatter *dateFormat = [NSDateFormatter new];
//correcting format to include seconds and decimal place
NSString* input = @"2014-02-07T03:10:59:434Z";
dateFormat.dateFormat = @"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
// Always use this locale when parsing fixed format date strings
NSLocale* posix = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
dateFormat.locale = posix;
NSDate* output = [dateFormat dateFromString:input];
Run Code Online (Sandbox Code Playgroud)