Reputation: 27
I have this Following date Formatter code
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"yyyy-MM-ddThh:mm:ss"];
NSDate *result = nil;
NSRange range = NSMakeRange(0, 10);
NSError *error = nil;
[df getObjectValue:&result forString:[msgColoums objectAtIndex:4] range:&range error:&error];
NSLog(@"Error in Parsing = %@", error);
INLog(@"Date From DF = %@", [df dateFromString:@"2011-12-14T16:31:26.0000000"]);
The code returns null
for the dateFromString
message.
The Error is NSInvalidValue=2011-12-14T16:31:26.0000000
.
If I change the formatting string to
[df setDateFormat:@"yyyy-MM-dd"];
then it will work, so the problem is in the time part.
Will someone please shed some light on this?
Upvotes: 1
Views: 78
Reputation: 47034
Try:
[df setDateFormat:@"yyyy-MM-dd'T'hh:mm:ss"];
to quote the literal T
Upvotes: 1