I am using JSF's 2.0 standard convertor tags to format some number output as currency. But i have a little problem, I dont know how to place the euro symbol at the end of the output.
This is what I did:
<h:outputText value="#{payment.amount}">
<f:convertNumber type="currency" currencySymbol="€"/>
</h:outputText>
The output I get is:
€15.55
But the desired output is:
15,55€
Can someone give me advice on how to solve this little issue?
In Statistics Explained articles the symbol '€' should be used for euro in the text if it is followed by a number. This applies also to graphs and tables. It should be placed before the figure: €30.
Tip: To quickly apply the Currency format, select the cell or range of cells that you want to format, and then press Ctrl+Shift+$. Like the Currency format, the Accounting format is used for monetary values. But, this format aligns the currency symbols and decimal points of numbers in a column.
For US dollars, the symbol '$' is sufficient abbreviation, unless there is a mixture of dollar currencies in the text. For other dollar currencies, '$' should be prefixed with the country abbreviation. For all other currencies, write the figure first followed by the currency name, for example, '100 million yuan'.
The format is dependent on the locale of the view. The locale can be set in 2 ways.
Generically by the locale
attribute of the <f:view>
tag:
<f:view locale="#{bean.locale}">
Specifically by the locale
attribute of the <f:convertNumber>
tag:
<f:convertNumber type="currency" currencySymbol="€" locale="#{bean.locale}" />
It's unclear what locale you're targeting, but the use of ,
as fraction separator and the placement of €
after the currency is typical for among others Germany (de-DE
), France (fr-FR
) and Portugal (pt-PT
). So you need to set it as such:
<f:convertNumber type="currency" currencySymbol="€" locale="pt-PT" />
It can also be obtained from a java.util.Locale
bean property.
Try this:
<h:outputText value="#{payment.amount}">
<f:convertNumber type="number" pattern="###,###.###€"/>
</h:outputText>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With