NSString *string = @"1990-04-15";
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
return [dateFormatter dateFromString:string];
this always return null,it functions ok when "string" changed by any other date string,is this date(1990-04-15) so special?
xcode 5 , IOS 7, iphone app
the whole method and context:
in "Tools.m":
+(NSDate *)stringToDate:(NSString *)string{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
return [dateFormatter dateFromString:string];
}
and the method called:
NSDate *date = [Tools stringToDate:@"1990-04-15"];
NSLog(@"---- the date:%@",date);