objective c - Date time formatting proglem in ios restkit -


I have a .NET Rest service that provides data in JSON format. UTC has a field date time that looks like this:

  "cicad": "2012-07-11T13: 28: 42.967"   

I Turning in to get this date in my iOS application, but every time I try to make myself I'm nullified:

  NSDateFormatter * dateFormatter = [NSDateFormatter new]; [DateFormatter setDateFormat: @ "yyyy-MM-dd'THH: mm: ssZ"]; DateFormatter.timeZone = [NSTimeZone timezone: Babe: @ "UTC"]; NSArray * dateFormatters = [[NSArray alloc] initWithObjects: dateFormatter, zero]; [RK object mapping set defaulted formatters: date formats];   

Am I doing wrong? Thanks!

Try this:

  NSDateFormatter * dateFormatter = [[NSDateFormatter Alloc] init]; [DateFormatter setDateFormat: @ "yyyy-MM-dd'THH: mm: sssss"]; DateFormatter.timeZone = [NSTimeZone timezone: Babe: @ "UTC"]; NSString * str = @ "2012-07-11T13: 28: 42.967"; // NSArray * dateFormatters = [[NSArray alloc] initWithObjects: dateFormatter, zero]; NSDate * date = [dateFormatter dateFromString: str];    

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -