Objective C / iPhone: How to extract actual Unicode date format strings for the current region?

According to this site: http://iosdevelopertips.com/cocoa/date-formatter-examples.html

there is a class that handles formatting that takes a set of constants / enumerations (e.g. NSDateFormatterShortStyle) to the setDateStyle property / method.

Somehow NSDateFormatter knows how to get the correct date format defined for the locale. I want to be able to get the default formats based on a custom selection of the region format. I have the feeling that it is stored in NSLocale, but it doesn’t look like it will retrieve format strings.

Is there any way to extract formats? It must be somewhere in the memory; I hope the search engine will be open somewhere.

I went through a few places, but the only answers I get is a lesson on how to create an NSDate from a custom format.

+2
source share
1 answer
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateStyle:NSDateFormatterShortStyle];
NSString *dateFormat = [df dateFormat];
NSLog(@"Date format: %@", dateFormat);
[df release];

Just tested on OS X, but this should also work on iOS.

+3
source

Source: https://habr.com/ru/post/1767937/


All Articles