在Objective C中将点转换为逗号数字格式

时间:2017-06-28 07:31:40

标签: ios objective-c nsnumberformatter

我正在尝试将数字从美国格式转换为欧洲格式。

输入:34.24 输出:34,24

我试过使用NSNumberFormatter但是没有用。有没有办法做到这一点?

NSString *dd = [NSString stringWithFormat:@"%0.2f",amountDouble];
NSNumberFormatter *formatString = [[NSNumberFormatter alloc] init];
[formatString setNumberStyle:NSNumberFormatterCurrencyStyle];
formatString.locale = Locale.currentLocale; //europe locale
NSNumber *reqNumber = [formatString numberFromString:dd]; // returns nil

1 个答案:

答案 0 :(得分:0)

尝试以下内容;

IF OBJECT_ID('tempdb..#dim') IS NOT NULL 

    DROP TABLE #dim

CREATE  TABLE #dim ([date] DATE)

if not @Begin_Date is null and not @End_Date is null

begin
    INSERT #dim([date])
    SELECT d
    FROM(

      SELECT
          d = DATEADD(DAY, rn - 1, @Begin_Date)
      FROM 
      (
          SELECT TOP (DATEDIFF(DAY, @Begin_Date, @End_Date)) 
              rn = ROW_NUMBER() OVER (ORDER BY s1.[object_id])
          FROM
              sys.all_objects AS s1
          CROSS JOIN
              sys.all_objects AS s2
          ORDER BY
              s1.[object_id]
      ) AS x
    ) AS y;
end