0

Here is the date sample: Wed, 13 May 2015 16:10:00 CEST

My formatter aint working

@"EEE, dd MMM yyyy HH:mm:ss vvvv"

What should i change?

UPD: full code

NSString* formattedDayWithString(NSString* date){
NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
NSLocale *locale = [NSLocale currentLocale];
NSString *localeId = [locale displayNameForKey:NSLocaleIdentifier
                                         value:[locale localeIdentifier]];

SLog(@"%@ date:%@", localeId, date);
[inputFormatter setLocale: locale];
[inputFormatter setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss vvvv"];
NSDate *formattedDate = [inputFormatter dateFromString: date];
NSDateFormatter *outputFormatter = [[NSDateFormatter alloc]init];
[outputFormatter setDateFormat:@"d'.' MMMM yyyy"];

NSString* dateStr = [[NSString alloc] initWithFormat: @"%@",[outputFormatter stringFromDate:formattedDate]];
return dateStr;

}

1 Answers1

0

"CEST" is a "short specific non-location format" and the corresponding date field symbol is "z", not "v":

[inputFormatter setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss z"];

In addition, you might have to set the date formatter locale explicitly to "en_GB" as explained in Nsdateformatter + Timezone issue.

Community
  • 1
  • 1
Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382