【问题标题】:iOS: NSNumberFormatter from local currency to doubleiOS:NSNumberFormatter 从本地货币翻倍
【发布时间】:2015-03-25 11:32:55
【问题描述】:

我有一个带有当地货币格式的货币字符串。 例如 10000 丹麦克朗将是 (10.000,00) 当转换为 double 值时,它只读取 10。 我试过这个 sn-p

NSString * locale ;
    if(locale == nil || [locale isEqualToString:@""]){
        locale = @"da_DK";
    }
   NSLocale *priceLocale = [[NSLocale alloc] initWithLocaleIdentifier:locale] ;
[NSDecimalNumber decimalNumberWithString:actualCash locale:priceLocale].doubleValue

但是没用

任何想法都会受到赞赏。

【问题讨论】:

    标签: ios localization nsnumberformatter


    【解决方案1】:

    直接使用NSNumberFormatter

    NSNumberFormatter* formatter = [NSNumberFormatter new];
    formatter.numberStyle = NSNumberFormatterDecimalStyle;
    formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"da_DK"];
    NSNumber* result = [formatter numberFromString:@"10.000,00"];
    

    【讨论】:

      猜你喜欢
      • 2016-10-10
      • 2013-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-20
      • 1970-01-01
      相关资源
      最近更新 更多