Question

I'm using the g:formatNumber tag to format a number as a currency

<g:formatNumber number="${it.price}" type="currency" currencyCode="${it.currency}"/>

This prints a formatted number such as

GBP6.87

is there some way that I can customise this? In particular, I would like there to be a space between the currency name and the amount, i.e.

GBP 6.87

Was it helpful?

Solution

You can specify your own format string to be whatever you want.

<g:formatNumber number="${myNumber}" format="your format here" />

See http://grails.org/doc/latest/ref/Tags/formatNumber.html and http://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top