从NSDateFormatterFullStylestring中删除一年

我已经search了这个问题,没有find一个决定性的和优雅的解决scheme。 是否有改变NSDateFormatterFullStyleyear抑制年份信息。 我正在使用的代码:

NSString *dateDescription; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; NSTimeZone *gmt = [NSTimeZone timeZoneWithAbbreviation:@"GMT"]; [dateFormatter setTimeZone:gmt]; [dateFormatter setDateStyle:NSDateFormatterFullStyle]; dateDescription = [dateFormatter stringFromDate:date]; NSLog(@"%@", dateDescription); 

结果:2013年3月13日星期三

问候,马科斯

以下是最接近你会得到没有很多棘手的string处理。 对dateFormatFromTemplate:options:locale:的调用将更新提供的模板以最佳地匹配指定的区域设置。

这假设正常的“全”风格给你星期几的名字,月份名称和月份的一天。

 NSString *fullMinusYear = [NSDateFormatter dateFormatFromTemplate:@"EEEE, MMMM dd" options:0 locale:[NSLocale currentLocale]]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:fullMinusYear]; NSString *dateDescription = [dateFormatter stringFromDate:date];