Returns NULL value
I get the null value when i print the log for sourceDate. it will give NULL value.
The code is:
NSMutableString * orignalStr = [[NSMutableString alloc] init];
[orignalStr appendString:date];
[orignalStr replaceOccurrencesOfString:@"T"
withString:@" "
options:NSCaseInsensitiveSearch
开发者_StackOverflow range:NSMakeRange(0, 15)];
NSLog(@"The orignalString is =%@ ",orignalStr);
NSDateFormatter* dateFormatter=[[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss zzz "];
NSDate *sourceDate =[dateFormatter dateFromString:orignalStr];
NSLog(@"The sourceDate is =%@ ",sourceDate);
plz help me...
Try using this date format string : @"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"
, without replacing occurences of @"T"
.
EDIT after comment
You got a string like : "2011-07-19 GMT:10:00", the format string should be @"yyyy'-'MM'-'dd' GMT:'HH':'ss"
.
精彩评论