Slee
Slee

Reputation: 28248

why am I getting a null value for this NSDate?

I am getting a NSDictionary back form a web service that looks like this when logged:

NSLog(@"dictionary: %@", dictionary);

Gives me:

dictionary: {
    BackOrderDate = "1/1/0001 12:00:00 AM";
    Quantity = 15;
}

So then I try and get a date from that:

NSDateFormatter *df = [[NSDateFormatter alloc] init];
NSDate *date = [df dateFromString: [dictionary objectForKey:@"BackOrderDate"]];

Logging this gives me a (null) but I know my dictionary has a value:

NSLog(@"setting back order date:%@ %@",date, [dictionary objectForKey:@"BackOrderDate"]);

Gives me:

setting back order date:(null) 3/1/2012 12:00:00 AM

Spending WAY to much time on this - what am I missing????

Upvotes: 0

Views: 287

Answers (1)

beryllium
beryllium

Reputation: 29767

I guess you missed

[df setDateFormat:@"dd/MM/yyyy HH:mm:ss aaa"];

Upvotes: 1

Related Questions