I am having problem displaying proper date in my app. When user sets 24 hour format 'ON' in his date time preferences..my app shows correct time but when 24 hour format is set to 'OFF' it shows nothing.

Here is the code I am using:

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

[formatter setDateStyle:style];

[formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
 NSDate *temp            =   [formatter dateFromString:strDate];

[formatter setDateFormat:format];
[formatter setLocale:[NSLocale currentLocale]];

NSString *returnStr     =   [formatter stringFromDate: temp];
[formatter release];
NSLog(@"Return: %@", returnStr);

return returnStr;
Edit
Report