VND currency format in Java?

public class JavaApplication15 {

public static void main(String[] args) {
double price = 20000000;
Locale locale = new Locale("vi", "VN");
Currency currency = Currency.getInstance("VND");

DecimalFormatSymbols df = DecimalFormatSymbols.getInstance(locale);
df.setCurrency(currency);
NumberFormat numberFormat = NumberFormat.getCurrencyInstance(locale);
numberFormat.setCurrency(currency);
System.out.println("Formatted currency: " + numberFormat.format(price));

// System.out.println("CURRENCY SYMBOL = " + df.getCurrencySymbol());
// System.out.println("DECIMAL SEPARATOR = " + df.getDecimalSeparator());
// System.out.println("GROUP SEPARATOR = " + df.getGroupingSeparator());
// System.out.println("CURRENCY CODE = " + df.getInternationalCurrencySymbol());
// System.out.println("DECIMAL PLACE = " + numberFormat.getMaximumFractionDigits());
// String sLP = ((DecimalFormat) numberFormat).toLocalizedPattern();
}
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s