Java DecimalFormat .setCurrency (Currency currency)
Syntax
DecimalFormat.setCurrency(Currency currency) has the following syntax.
public void setCurrency(Currency currency)
Example
In the following code shows how to use DecimalFormat.setCurrency(Currency currency) method.
//from w ww . j a va 2s.c om
import java.text.DecimalFormat;
import java.util.Currency;
import java.util.Locale;
public class Main {
public static void main(String[] argv) throws Exception {
DecimalFormat format = new DecimalFormat();
format.setCurrency(Currency.getInstance(Locale.GERMANY));
System.out.println(format.getCurrency());
}
}
The code above generates the following result.