B
Bobby Quinne
Hi there,
I have been having an issue attempting to retrieve the currency symbol
from the currency code.
Basically I am just given the currency code(EG: USD) and I can expect
multiple currency codes to be supplied.
Using :
java.util.Currency.getInstance("USD").getSymbol();
returns USD. Not what I want.
Using :
java.util.Currency.getInstance("USD").getSymbol(java.util.Locale.US);
does return $ which is what I want.
In this instance I am clearly explicitly using Locale.US. Now from
what I can see there is no easy way to get the Locale from the
currency code.
What I have tried :
1. Coded a static lib with an array of the predefined Locales in
java.util.Locale. It does work and return me the symbol but there are
less than 10 predefined Locale(others in there are for Language). Also
adding new definitions to the array is not appealing.
2. Tried jscience-4.3.1 but from the examples
http://jscience.org/api/org/jscience/economics/money/package-summary.html
it looks like the symbol needs to be setup in code. Same issue as the
above having to add definitions and recompile if new additions come
along.
Is there something glaringly obvious I am missing?
Is there perhaps a framework that makes this easy?
Currently I am looking through the JRE and seeing where the resource
data is. Java tutorial makes mention of ResouceBundles for i18n.
Many thanks to any assistance lended.
I have been having an issue attempting to retrieve the currency symbol
from the currency code.
Basically I am just given the currency code(EG: USD) and I can expect
multiple currency codes to be supplied.
Using :
java.util.Currency.getInstance("USD").getSymbol();
returns USD. Not what I want.
Using :
java.util.Currency.getInstance("USD").getSymbol(java.util.Locale.US);
does return $ which is what I want.
In this instance I am clearly explicitly using Locale.US. Now from
what I can see there is no easy way to get the Locale from the
currency code.
What I have tried :
1. Coded a static lib with an array of the predefined Locales in
java.util.Locale. It does work and return me the symbol but there are
less than 10 predefined Locale(others in there are for Language). Also
adding new definitions to the array is not appealing.
2. Tried jscience-4.3.1 but from the examples
http://jscience.org/api/org/jscience/economics/money/package-summary.html
it looks like the symbol needs to be setup in code. Same issue as the
above having to add definitions and recompile if new additions come
along.
Is there something glaringly obvious I am missing?
Is there perhaps a framework that makes this easy?
Currently I am looking through the JRE and seeing where the resource
data is. Java tutorial makes mention of ResouceBundles for i18n.
Many thanks to any assistance lended.