iPhone,如何获取设备短日期格式?

时间:2010-10-27 08:53:36

标签: iphone objective-c xcode

我没有设备价格格式设置。

NSNumber *temp = [NSNumber numberWithDouble:dblPrice];
NSDecimalNumber *someAmount = [NSDecimalNumber decimalNumberWithDecimal:[temp decimalValue]];

NSNumberFormatter *currencyFormatter = [[[NSNumberFormatter alloc] init] autorelease];
[currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];

return [currencyFormatter stringFromNumber:someAmount];

如何获取短日期设置?

1 个答案:

答案 0 :(得分:14)

NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
NSString *dateString = [dateFormatter stringFromDate:[NSDate date]];