cancel
Showing results for 
Search instead for 
Did you mean: 

How to unformat currency in Fiori/UI5

Former Member

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

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member228602
Contributor

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

nimiprave
Advisor
Advisor
0 Kudos

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()));