Dónal
Dónal

Reputation: 187379

formatting numbers as currencies

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

Upvotes: 4

Views: 2103

Answers (1)

Jeff Scott Brown
Jeff Scott Brown

Reputation: 27255

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.

Upvotes: 4

Related Questions