当我打印sourceDate的日志时,我得到空值。 它会给NULL值。返回NULL值
的代码是:
NSMutableString * orignalStr = [[NSMutableString alloc] init];
[orignalStr appendString:date];
[orignalStr replaceOccurrencesOfString:@"T"
withString:@" "
options:NSCaseInsensitiveSearch
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帮助我...
'originalString'的日志输出是什么? – 2011-07-21 07:17:03
The Log应该是这样的.. 2011-07-21 12:25:38.814 GameTimeBaseBall [1270:207] orignalString = 2011-07-19 19 GMT:10:00 2011-07-21 12:25: 38.815 GameTimeBaseBall [1270:207] dateFormatter is = 2011-07-21 12:25:38.815 GameTimeBaseBall [1270:207] sourceDate =(null) –
不,我没有得到 –