简体   繁体   English

为什么我得到此NSDate的空值?

[英]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: 我从网络服务获得NSDictionary的登录信息,如下所示:

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???? 在这方面花很多时间-我想念什么????

我想你错过了

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM