remove year for date format in respect to the users locale

cocoa-touch, ios, localization, nsdateformatter, objective-c

Solution

I found the answer myself:

[self.dateFormatter setDateFormat:[NSDateFormatter dateFormatFromTemplate:@"MM d"
                                                                  options:0 
                                                                   locale:[NSLocale currentLocale]]];

See more at apple documentation on `dateFormatFromTemplate`

Problem

I want to display the day and the month in respect to the locale of the users device. So that the date of today would be displayed as 5/18 with american settings and 18.5. with german setting. As I want to handle every possible locale, I cant just simply use the `[dateFormatter setDateFormat:]` and `[dateFormatter setDateStyle:NSDateFormatterShortStyle]` will display the year. Beside trying to identify the year value in the string and removeing it, is there a more elegant way?

Original source