zoukankan      html  css  js  c++  java
  • iOS开发字符串处理篇之货币格式化

    一、货币格式化

      NSNumberFormatter *currencyFormatter = [[NSNumberFormatter alloc] init];
        currencyFormatter.numberStyle = kCFNumberFormatterDecimalStyle;
        NSString *currenctStr = [currencyFormatter stringFromNumber:[NSNumber numberWithInteger:currencyNumber]];
        return [NSString stringWithFormat:@"¥%@",currenctStr];//因为我需要的样式是¥123,456,789没有后面的.00
        /*
        NSNumberFormatterNoStyle = kCFNumberFormatterNoStyle,  // 123456789
        NSNumberFormatterDecimalStyle = kCFNumberFormatterDecimalStyle,// 123,456,789
        NSNumberFormatterCurrencyStyle = kCFNumberFormatterCurrencyStyle,//¥123,456,789.00
        NSNumberFormatterPercentStyle = kCFNumberFormatterPercentStyle, //-539,222,988%
        NSNumberFormatterScientificStyle = kCFNumberFormatterScientificStyle,//1.23456789E8
        NSNumberFormatterSpellOutStyle = kCFNumberFormatterSpellOutStyle //一亿二千三百四十五万六千七百八十九
         */
    

      

  • 相关阅读:
    Gym
    Gym
    Gym
    Gym
    Gym
    bzoj 2734: [HNOI2012]集合选数
    bzoj 1068: [SCOI2007]压缩
    HDU 2899 Strange fuction
    hihocoder #1142 : 三分·三分求极值
    HDU 2824 The Euler function
  • 原文地址:https://www.cnblogs.com/TheYouth/p/8377628.html
Copyright © 2011-2022 走看看