1
votes

I have a German customer, he wants some numbers on his page to be

4,3

instead of

4.3

as I cant set the Number format globally for the project or controller because i have javascript depending on the english format, I'm looking for a simple replace method in gsp something like

${number.replace(/./,",")}

but that causes

No signature of method: java.lang.Double.replace() is applicable for argument types: (java.lang.String, java.lang.String)

any idea ? thanks in advance

2

2 Answers

7
votes

Instead of doing string conversion stuff, do it like this:

${formatNumber(number: number, locale: Locale.GERMAN, format: '##0.00')}
3
votes

take a look at http://grails.org/doc/2.3.x/ref/Tags/formatNumber.html

You should be able to format the number properly using the locale.