Java Currency Formatter Changing $ to ¤
Java currency formatting problem.
Following code shows the conditions when the currency symbol is replaced by an alt currency symbol.
public class Test {
public static void main(String[] args){
double num = 1323.526;
Locale eng = new Locale("", "");
NumberFormat engFormat = NumberFormat.getCurrencyInstance(eng);
System.out.println(engFormat.format(num));
eng = new Locale("en", "");
engFormat = NumberFormat.getCurrencyInstance(eng);
System.out.println(engFormat.format(num));
eng = new Locale("en", "en_US");
engFormat = NumberFormat.getCurrencyInstance(eng);
System.out.println(engFormat.format(num));
eng = new Locale("", "US");
engFormat = NumberFormat.getCurrencyInstance(eng);
System.out.println(engFormat.format(num));
eng = new Locale("en", "US");
engFormat = NumberFormat.getCurrencyInstance(eng);
System.out.println(engFormat.format(num));
eng = new Locale("blah", "US");
engFormat = NumberFormat.getCurrencyInstance(eng);
System.out.println(engFormat.format(num));
}
}
Output :
¤ 1,323.53
¤1,323.53
¤1,323.53
USD 1,323.53
$1,323.53
USD 1,323.53
Comments
Post a Comment