How can I display different currencies in my JSP pages according to the location of the client.

Byron Tymvios

You can do this by using the Locale of the user (which can be obtained from request.getLocale() and passing it to a NumberFormat object. You can then format your number and it will automagically have the correct currency sign preceeding the value.

// The number to display
double val = 12345d;

Locale locale = request.getLocale();
String toDisplay = NumberFormat.getCurrencyInstance(locale).format(val);

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact