Skip to Content
0

How to unformat currency in Fiori/UI5

Jan 27, 2017 at 06:51 PM

74

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Veeraraghavan Narasimhan
Jan 28, 2017 at 03:53 AM
1

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

Share
10 |10000 characters needed characters left characters exceeded
Nirmal Pothuraj
Jan 28, 2017 at 07:52 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded