如何在iOS中获取本地格式化的日期图案字符串?

Joh*_*und 1 objective-c nsdate nsdateformatter ios ios5

可能重复:
如何确定区域设置的日期格式是月/日还是日/月?

我现在已经挣扎了一段时间而且我被卡住了!我要么需要一个"mm-dd-yyyy"或"08-25-2012"形式的本地格式化模式日期字符串.我该怎么做?用dateFormat吗?请帮我!

Jes*_*mpo 9

NSDateFormatter有一个便捷类方法:

[NSDateFormatter localizedStringFromDate:date dateStyle:NSDateFormatterShortStyle timeStyle:NSDateFormatterNoStyle];
Run Code Online (Sandbox Code Playgroud)

您可以指定NSDateFormatterNoStyle,.. ShortStyle,.. MediumStyle或..LongStyle