-3

I am trying to convert string 2013-04-18T06:53:26-04:00 to NSDate. Here is my code.

NSDateFormatter *rfc3339DateFormatter = [[NSDateFormatter alloc] init] ;
NSLocale *enUSPOSIXLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
assert(enUSPOSIXLocale != nil);

[rfc3339DateFormatter setLocale:enUSPOSIXLocale];
[rfc3339DateFormatter setDateFormat:@"yyyy-MM-ddTHH:mm:ssZZZZ"];
NSLog(@"str %@",[rfc3339DateFormatter dateFromString:@"2013-04-18T06:53:26-04:00"]);

I am getting always (null)

Joachim Isaksson
  • 176,943
  • 25
  • 281
  • 294
Jasmin Mistry
  • 1,459
  • 1
  • 18
  • 23

1 Answers1

0

Solved with this

[rfc3339DateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZZZZ"];
Jasmin Mistry
  • 1,459
  • 1
  • 18
  • 23