【问题标题】:NSNumberFormatter for 2 Decimal PlacesNSNumberFormatter 用于 2 个小数位
【发布时间】:2021-02-23 11:59:49
【问题描述】:

我有一些想要以本地样式显示的数量。

NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc]init];
numberFormatter.locale = [NSLocale currentLocale];
numberFormatter.numberStyle = NSNumberFormatterCurrencyStyle;
numberFormatter.usesGroupingSeparator = YES;

NSString* amountText = [NSString stringWithFormat:@"ab %@€",[numberFormatter stringFromNumber:someDoubleNumber]];

问题是这也显示货币,这是我不想要的。基本上我正在寻找的是显示十进制应该根据本地样式,小数点后有2个数字,例如0.00或德国0,00,我的代码我达到了这个要求,但我也得到了额外的货币符号我不想要。

【问题讨论】:

    标签: ios objective-c number-formatting nsnumberformatter


    【解决方案1】:

    还有人在寻找我的答案

    [numberFormatter setCurrencySymbol:@""];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-09-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多