数字值为120000。
答案 0 :(得分:6)
您可以使用NSNumberFormatterCurrencyStyle获得所需的结果。
NSNumberFormatter *indCurrencyFormatter = [[NSNumberFormatter alloc] init];
[indCurrencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[indCurrencyFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_IN"]];
NSString *formattedString = [indCurrencyFormatter stringFromNumber:[NSNumber numberWithFloat:120000]];
答案 1 :(得分:1)
示例:强>
NSNumberFormatter *numberFormatter = [NSNumberFormatter new];
[numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle]; // Here you can choose the style
NSString *formatted = [numberFormatter stringFromNumber:[NSNumber numberWithInteger: 120000]];
或者您可以使用:
[[NSLocale currentLocale] objectForKey:NSLocaleGroupingSeparator]
<强>更新强>
在印度货币格式中,您必须将@"en_IN"
设置为numberFormatter Locale
,只需添加以下行:
[numberFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_IN"]];
答案 2 :(得分:1)
NSDecimalNumber *price = [NSDecimalNumber decimalNumberWithString:@"120000"];
NSLocale *priceLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en-in"];
NSNumberFormatter *currencyFormatter = [[NSNumberFormatter alloc] init];
[currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[currencyFormatter setLocale:priceLocale];
NSString *format = [currencyFormatter positiveFormat];
[currencyFormatter setPositiveFormat:format];
NSString *currencyString1 = [currencyFormatter stringFromNumber:price];
DLog(@"%@",currencyString1);