Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to place the euro symbol for currency at the end and not at the beginning of an output?

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?

like image 476
javing Avatar asked Oct 11 '11 10:10

javing


People also ask

Do you put € before or after the amount?

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.

How do I align currency symbol in Excel?

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.

What is the correct way to write currency?

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'.


2 Answers

The format is dependent on the locale of the view. The locale can be set in 2 ways.

  1. Generically by the locale attribute of the <f:view> tag:

    <f:view locale="#{bean.locale}">
    
  2. Specifically by the localeattribute 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.

like image 124
BalusC Avatar answered Sep 24 '22 17:09

BalusC


Try this:

<h:outputText value="#{payment.amount}">
    <f:convertNumber type="number" pattern="###,###.###€"/>
</h:outputText>
like image 45
Matt MacLean Avatar answered Sep 22 '22 17:09

Matt MacLean