i have a function to convert into NSDate
by using NSDateFormatter
.
+(NSDate*)getDateFromCurrentTimestamp:(NSString*)currentTimestamp{
// currentTimestamp= @"28-Feb-2012 16:42:19 PM";
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDoesRelativeDateFormatting:NO];
[dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
[dateFormatter setFormatterBehavior:NSDateFormatterShortStyle];
//[NSDateFormatter setDefaultFormatterBehavior:NSDateFormatterBehaviorDefault];
[dateFormatter setDateFormat:@"dd-MMM-yyyy HH:mm:ss a"];
return [dateFormatter dateFromString:currentTimestamp];
}
IOS 5.x is returned correct NSDate
.
when run on 4.1 & 4.2 also returned correct NSDate
.
when run on 4.3.2 & 4.3.3, it's returned null
.
how is it possible? any workaround of this?
EDIT
This is not caused by iOS bug. this is related to phone itself. some phone has different locale
set in device. so we had to force it to use one locale
.