【发布时间】:2013-07-06 02:30:50
【问题描述】:
我在我的 gsp 中使用g:formatNumber 标记来格式化货币,就像这样
<g:formatNumber number="${value}" type="currency" currencyCode="USD" />
这对正数很有效,但由于某种原因,负数的格式为($0.45) 而不是-$0.45。
有没有办法解决这个问题?
【问题讨论】:
我在我的 gsp 中使用g:formatNumber 标记来格式化货币,就像这样
<g:formatNumber number="${value}" type="currency" currencyCode="USD" />
这对正数很有效,但由于某种原因,负数的格式为($0.45) 而不是-$0.45。
有没有办法解决这个问题?
【问题讨论】:
这是英语语言环境的标准货币格式。您可以更改格式化程序区域设置(不要认为这是您想要的),或使用自定义格式,例如:
<g:formatNumber number="${value}" format="$#.##" />
十进制格式见文档:http://docs.oracle.com/javase/1.5.0/docs/api/java/text/DecimalFormat.html
【讨论】: