You can parse and convert currency amounts with these currency converters:


The currency converter translates a value into the currency pattern of the recognized locale. For example:

<dsp:valueof bean="PriceInfo.amount" converter="currency"/>

In this example, no locale is specified, so the converter first looks for a request parameter named locale, which can be either a java.util.Locale object or a String that names a locale. If this parameter cannot be found, the converter gets the locale from the RequestLocale.

The following example explicitly specifies a locale:

<dsp:valueof locale="en_US" bean="PriceInfo.amount" converter="currency"/>

This example might display a value of $13.89. Each locale provides a default setting that determines:

For more information on tailoring your site to an international audience, see the Internationalization chapter in the ATG Programming Guide.

euro and currencyConversion

If you need to display prices in more than one currency on your site, the euro and currencyConversion converters are especially useful. These converters are child classes of the currency converter. You can store prices in euros, and then use the currencyConversion converter to automatically convert the prices to another currency. For example:

<p>Price in Euros:  <dsp:valueof locale="en_UK"
   bean="PriceInfo.amountInEuros" converter="euro" symbol="&euro"/>
<p>Price in British Pounds:  <dsp:valueof locale="en_UK"
   bean="PriceInfo.amountInEuros" converter="currencyConversion"/>

In this example, the first dsp:valueof tag displays the price in euros. The symbol attribute is used to specify the HTML entity for the euro symbol because the ISO Latin-1 (ISO 8859-1) character set does not include this symbol. The locale attribute is used to determine how to format the output. The second dsp:valueof tag displays the price in British pounds, using the official exchange rate set by the European Union and published at (The exchange rate is stored in the resource file atg/droplet/

If the locale indicates a country that does not use the euro (such as the United States), these converters return null, and the dsp:valueof tag returns its default value. For example:

<dsp:valueof bean="priceInfo.amountInEuros" converter="currencyConversion">$5.00</dsp:valueof>

In this tag, the locale attribute is not specified, so locale is determined as described above. If the locale is a country that uses the euro, the value of priceInfo.amountInEuros is converted to the appropriate currency (using the official exchange rates) and displayed in the appropriate format for that locale. If the locale is not a country that uses the euro, the price is displayed as $5.00.

The currencyConversion tool also includes a reverse attribute that you can use to convert from a locale-specific European currency (for example, British pounds) into euros. Again, the conversion is performed using the official EU rate.

<dsp:valueof locale="en_UK_EURO" bean="priceInfo.amountInEuros" reverse="true"
 converter="currencyConversion" symbol="&euro;">no price</dsp:valueof>

In this example, the amount stored in priceInfo.amountInEuros is converted to euros and the optional symbol attribute is used to display the euro character. In addition, the en_UK_EURO value tells it to format the euro value appropriately for the specified locale—in this case, United Kingdom.

See the Internationalization chapter of the ATG Programming Guide for more information about locales.

loading table of contents...