Skip to Content
avatar image
Former Member

How to unformat currency in Fiori/UI5

Hello,

I have an input field that is formatted with standard currency. So if I'm in

in Europe

1000.00 shows up as 1.000,00

In USA

1000.00 shows up as 1,000.00

Is there a clean way to format from the standard currency formatter to the a standard float. The oData layer is expecting 1000.00.

Best regards

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Jan 28, 2017 at 03:53 AM

    Hello ,

    The currency formatting you suggest is ideally meant for display purposes only. Which is why some controls have attributes like format and display format. The underlying should ideally store only 1000 and and not as 1,000 or 1.000 . Are you using a oData model or a json model . There are some formatter available in sapui5 . More on them can be found here Number Formatting . You will find grouping enabled flag to ensure grouping is not enabled.

    But for a better recommendation need some snippet to understand the problem better.

    Thanks and Regards,

    Veera

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 28, 2017 at 07:52 PM

    You can use the NumberFormat API to parse the formatted content to the float as shown below.

    var oNumberFormat = sap.ui.core.format.NumberFormat.getFloatInstance({ maxFractionDigits: 2, groupingEnabled: false });

    oNormalFormat.parse(view.byId("your Input control").getValue()));

    Add comment
    10|10000 characters needed characters exceeded