I don't seem to have very many Locales loaded... but france uses a trailing symbol, taiwan uses a leading symbol.
public class MyCurrency {
public static void main(String[] args) {
System.out.println(format(Locale.FRANCE, 1234.56f));
System.out.println(format(Locale.TAIWAN, 1234.56f));
}
public static String format(Locale locale, Float value) {
NumberFormat cfLocal = NumberFormat.getCurrencyInstance(locale);
return cfLocal.format(value);
}
}
Now if you really want to know if the currency symbol is at the beginning or the end, use the following as a starting point. Note the bPre
variable...
public String format(Locale locale, Float value) {
String sCurSymbol = "";
boolean bPre = true;
int ndx = 0;
NumberFormat cfLocal = NumberFormat.getCurrencyInstance(locale);
if (cfLocal instanceof DecimalFormat) { // determine if symbol is prefix or suffix
DecimalFormatSymbols dfs =
((DecimalFormat) cfLocal).getDecimalFormatSymbols();
sCurSymbol = dfs.getCurrencySymbol();
String sLP = ((DecimalFormat) cfLocal).toLocalizedPattern();
// here's how we tell where the symbol goes.
ndx = sLP.indexOf('\u00A4'); // currency sign
if (ndx > 0) {
bPre = false;
} else {
bPre = true;
}
return cfLocal.format(value);
}
return "???";
}
Credit - I ripped the code from this page. http://www.jguru.com/faq/view.jsp?EID=137963