Example to print formatted currency with NumberFormat.getCurrencyInstance():
package java_numberformat;
import java.text.NumberFormat;
import java.util.Locale;
/**
* @web java-buddy.blogspot.com
*/
public class Java_NumberFormat {
public static void main(String[] args) {
double val = 12345.6789;
System.out.println("US:\t" + NumberFormat
.getCurrencyInstance(Locale.US)
.format(val));
System.out.println("CHINESE:\t" + NumberFormat
.getCurrencyInstance(Locale.CHINESE)
.format(val));
System.out.println("CHINA:\t" + NumberFormat
.getCurrencyInstance(Locale.CHINA)
.format(val));
System.out.println("UK:\t" + NumberFormat
.getCurrencyInstance(Locale.UK)
.format(val));
System.out.println("GERMANY:\t" + NumberFormat
.getCurrencyInstance(Locale.GERMANY)
.format(val));
System.out.println("GERMAN:\t" + NumberFormat
.getCurrencyInstance(Locale.GERMAN)
.format(val));
System.out.println("FRANCE:\t" + NumberFormat
.getCurrencyInstance(Locale.FRANCE)
.format(val));
System.out.println("FRENCH:\t" + NumberFormat
.getCurrencyInstance(Locale.FRENCH)
.format(val));
System.out.println("ITALIAN:\t" + NumberFormat
.getCurrencyInstance(Locale.ITALIAN)
.format(val));
System.out.println("ITALY:\t" + NumberFormat
.getCurrencyInstance(Locale.ITALY)
.format(val));
}
}
|
print formatted currency with NumberFormat.getCurrencyInstance() |
No comments:
Post a Comment