views:

177

answers:

1

Hey all,

i simple try to reformat a date:

 NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
 NSDate *date = [[NSData alloc] init];
 //Mon, 05 Apr 2010 14:27:48 -0700
 [formatter setDateFormat:@"E, dd MMM yyyy HH:mm:ss Z"];
 date = [formatter dateFromString:self.currentItemValue];        

 [formatter setDateFormat:@"yyyy-MM-dd HH:mm"];
 self.currentItem.pubDate = [formatter stringFromDate:date];
 [formatter release];

It works on the simulator, but on the device i only get (null).

Thanks for your help!

Some more tests:

NSString *string = @"Fri, 12 Dec 2008 18:45:15 -0800";
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
dateFormatter setDateFormat:@"EEE, d MMM yyyy HH:mm:ss Z"];
NSDate *date = [dateFormatter dateFromString:string];
[dateFormatter setDateStyle:NSDateFormatterLongStyle];
//here i got (null) on the device but it works on simulator...
NSLog(@"date %@", [dateFormatter stringFromDate:date]);
+1  A: 

DyingCactus was right!

[dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_GB"] autorelease]];

solves my issue.... Thanks!!!!

phx