How to parse a EU decimal to US decimal?

0
Hello, I have a few strings which I want to convert into a decimal number. The strings look like this “12.386,88” they are in EU format, I want to parse them to a US decimal number and do some calculations with them. How can I parse them to a US decimal (12,386.88)?   How can I change the decimal seperator from . to ,?
asked
2 answers
2

Bertran,

I did some Forum research and found reference to user language settings.  Another approach is to use a microflow like the one below:

The function in the second Activity is:

replaceAll($EuroDecimal,'\Q.\E','')

The function in the third Activity is:

replaceAll($EuroDecimal,'\Q,\E','.')

Documentation on string functions can be found here:

String Function Calls Documentation

Hope that helps,

Mike

answered
2

I was interested to see this problem, and I felt there was a better way to solve it, so I have written a module to parse different decimal formats. Look for Decimal Tools in the Marketplace

https://marketplace.mendix.com/link/component/119981

This has a Java Action called ParseDecimal that allows you to pass in the decimal string, a format, a decimal separator, and a grouping separator. It uses the same decimal parsing Mendix uses itself, but exposes those extra parameters so you can parse decimals that use a different format from your locale.

In this case, you’d set the decimal separator to ‘,’ and the grouping separator to ‘.’ .

answered