My iOS application supports 6 languages. Now I want to show localized month names.
e.g. January in French will show "Janvier"
For this I have below code while converting date from UTC to local time zone
-(NSString *)getLocalDateFromUTCFormattedDate:(NSString*)utcDate
{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSTimeZone *sourceTimeZone = [NSTimeZone timeZoneWithName:@"UTC"];
[dateFormatter setTimeZone:sourceTimeZone];
[dateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH:mm:ss'Z'"];
NSDate *dateFromServer = [dateFormatter dateFromString:utcDate];
// Now convert to local date
dateFormatter.locale = [NSLocale systemLocale];
[dateFormatter setDateFormat:@"dd MMMM yyyy"];
NSTimeZone* localTimeZone = [NSTimeZone systemTimeZone];
[dateFormatter setTimeZone:localTimeZone];
NSString *localDate = [dateFormatter stringFromDate:dateFromServer];
return localDate;
}
But month name is still in english even after I change the language to french / japanese. I got this link , but I don't want to hardcode the locale. So I have used
dateFormatter.locale = [NSLocale systemLocale];
But no luck. Can anybody tell me whats wrong in this ?