I am trying to format a given number to European format. However, I am getting result in US/UK format only.
Here is my code:
static async formatCurrency(numberIn: number, currencyIndicator: string) {
if(currencyIndicator=='EUR') {
console.log(numberIn.toLocaleString('es-ES', { minimumFractionDigits: 2 , style: 'currency', currency: 'EUR'}));
console.log(Number(numberIn).toLocaleString("de-DE", {minimumFractionDigits: 2}));
}
}
await formatCurrency(12345678.00,"EUR");
Here is my output:
€12,345,678.00
12,345,678.00
The output I am expecting is:
€12.345.678,00
12.345.678,00
I tried installing full-icu and importing it to my class. With this code I am still not getting desired result:
formattedNumber = await new Intl.NumberFormat('nl-NL', { minimumFractionDigits: 2 , style: 'currency', currency: 'EUR'}).format(numberIn);
console.log("formattedNumber is: " + formattedNumber);
This is what I get as output: €12,345,678.00. Instead of €12.345.678,00
May be this will be better solution?
formattedNumber = await formattedNumber.replace(/\./g, "_");
formattedNumber = await formattedNumber.replace(/,/g, ".");
formattedNumber = await formattedNumber.replace(/_/g, ",");
```
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.