Невозможно отформатировать дату в формате UTC с помощью NSDateFormatter

У меня есть следующая дата:

2011-10-20T01:10:50Z

Я бы хотел, чтобы она была отформатирована в

"M/d/yy 'at' h:mma"

Вот мой код:

NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
    //The Z at the end of your string represents Zulu which is UTC
    [dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
    [dateFormatter setDateFormat:@"yyyy-dd-MM'T'HH:mm:ss'Z'"];
    NSDate* newTime = [dateFormatter dateFromString:[message valueForKey:@"created_at"]];

    //Add the following line to display the time in the local time zone
    [dateFormatter setTimeZone:[NSTimeZone systemTimeZone]];
    [dateFormatter setDateFormat:@"M/d/yy 'at' h:mma"];
    NSString* finalTime = [dateFormatter stringFromDate:newTime];
    [dateFormatter release];
    NSLog(@"%@", finalTime);    

К сожалению, finalTime здесь NULL.

18
задан Sheehan Alam 20 October 2011 в 01:52
поделиться