NSDateFormatter returns null for specific dates
I'm having a problem with the NSDateFormatter . It is returning null for some specific dates. I did this function to debug the case: - (void) debugTest:(NSString *)dateStr{ NSLog(@"String: %@", dateStr); NSDateFormatter *df = [[NSDateFormatter alloc] init]; [df setDateFormat:@"yyyy-MM-dd"]; NSDate *dateObj = [df dateFromString: dateStr]; NSLog(@"Date: %@", dateObj); } This is my log output for some dates: String: 2012-10-18 Date: 2012-10-18 03:00:00 +0000 String: 2012-10-19 Date: 2012-10-19 03:00:00 +0000 String: 2012-10-20 Date: 2012-10-20 03:00:00 +0000 String: 2012-10-21 Date: (null) String