import java.text.NumberFormat;
import java.util.Locale;
public class MainClass{
public static void main(String[] argv){
Locale[] locales = { Locale.US, Locale.TAIWAN };
for (Locale loc:locales) {
NumberFormat f = NumberFormat.getCurrencyInstance(loc);
String formattedMoney = f.format(123.45);
System.out.format("%15s: %s\n",
loc.getDisplayCountry(),
formattedMoney);
}
}
}
|