views:

24

answers:

1

Hi. I was parsing a XML feed and trying to convert it to a NSObject when I noticed that (e.g.) [NSDate dateFromString:@"Tue, 23 Feb 2010 06:00:44 PST"] returned nil. Then I tried to convert my string to a NSDate by using the NSDateFormatter.

NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"EEE, dd MMM YYYY HH:mm:ss zzz"];
NSDate *d = [df dateFromString:@"Tue, 23 Feb 2010 06:00:44 PST"];

But this still returns nil. I think my problem is that my Unicode Data Markup is wrong. I have no idea how it should look like.
For more information about the Unicode Locale Data Markup Language look here.

Thank you for every of your ideas!

A: 

The formatter was set to the wrong locale.

[df setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]];

This helped. I also changed "YYYY" to "yyyy". The solution was found here.

papr