Decimal to String in European currency format

0
Hi everyone, I’m working on a Mendix app for Portugal and I need to display money values in the European format, for example: 10.560,69 €. The value I’m working with comes as a decimal, like 10560.69, and when I convert it to a string using toString(), it just shows '10560.69', which uses a dot as the decimal separator and doesn’t match the format expected by users in Portugal. I’d like to show the value as a properly formatted currency, with a comma for decimals and a dot for thousands, like we use in Portugal. What is the best way to do this in Mendix when the value is a decimal but needs to be stored or displayed as a formatted string? Thanks.
asked
2 answers
2

Hey Luciano,

The formatting of decimal numbers is directly linked to the application language.

image.png 

 

You can use functions such as formatDecimal to customize your output.

Depending on the situation, it may be necessary to replace , with . or vice versa, but this is not recommended.

 

Best Regards,

Ricardo Pereira

answered
2

You will need to use the formatDecimal function, not toString. For example...

 

formatDecimal(10560.69, '#,##0.00', 'pt-PT')

 

https://docs.mendix.com/refguide/parse-and-format-decimal-function-calls/#formatDecimal

 

You can optionally specify the locale in the last parameter. If you want Portuguese, I think this is 'pt-PT'. 

answered