PDA

View Full Version : Problem in NSDateFormatter class


sunil
2008.12.12, 10:02 AM
Hi Guyes,

I am using below mentioned code to get the Lacale date format, it is wokring on Mac machine but not on iPhone.

[NSDateFormatter setDefaultFormatterBehavior:NSDateFormatterBehavio r10_4];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
[dateFormatter setTimeStyle:NSDateFormatterNoStyle];

NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];

[inputFormatter setDateFormat:@"yyyy-MM-dd"];
NSDate *date = [inputFormatter dateFromString:@"2008-12-13"];
NSString *formattedDateString = [dateFormatter stringFromDate:date];
NSLog(@"Locale ==========%@ formatttedDateString=========%@ \n", [[dateFormatter locale] localeIdentifier],formattedDateString);


Please help me to resolve this problem?

Thanks in advance.

Sunil

Derek Kuhl
2008.12.12, 02:29 PM
HOW doesn't it work? Crash? Something returning as nil?