日期格式 – 时区

我从服务器收到一个字符串,其日期如下:“2013-03-29T15:27:00Z”。 如何格式化并将其转换为NSDate?

尝试这个:

[NSDateFormatter setDefaultFormatterBehavior:NSDateFormatterBehavior10_4]; NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease]; [formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"]; NSDate *date = [formatter dateFromString:@"2013-03-29T15:27:00Z"]; 
  NSString *departTimeDate = @"2013-03-29T15:27:00Z"; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"]; NSDate *date = [dateFormatter dateFromString:departTimeDate]; NSLog(@"Expected Result___ %@",date); 
 NSString *string=@"2013-03-29T15:27:00Z"; NSDateFormatter *dateFormatter=[NSDateFormatter new]; [dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'Z'"]; NSDate *date=[dateFormatter dateFromString:string];