DecimalFormat getCurrency() method in Java Last Updated : 01 Apr, 2019 Comments Improve Suggest changes Like Article Like Report The getCurrency() method is a built-in method of the java.text.DecimalFomrat class in Java and is used to return the currency which is used while formatting currency values by this currency. It can be null if there is no valid currency to be determined or if no currency has been set previously. Syntax: public Currency getCurrency() Parameters: The function does not accepts a single parameter. Return Value: The function returns the currency which is used while formatting currency values. Errors and Exceptions: The function throws UnsupportedOperationException when the number format class doesn’t implement currency formatting Below is the implementation of the above function: Program 1: Java // Java program to illustrate the // getCurrency() method import java.text.DecimalFormat; import java.util.Currency; import java.util.Locale; public class Main { public static void main(String[] args) { // Get the Currency Instance DecimalFormat deciFormat = new DecimalFormat(); // Stores the values String values = deciFormat.getCurrency() .getDisplayName(); // Prints the currency System.out.println(values); } } Output: US Dollar Program 2: Java // Java program to illustrate the // getCurrency() method import java.text.DecimalFormat; import java.util.Currency; import java.util.Locale; public class Main { public static void main(String[] args) { // Get the Currency Instance DecimalFormat deciFormat = new DecimalFormat(); // Sets the currency to Canadian Dollar deciFormat.setCurrency( Currency.getInstance( Locale.CANADA)); // Stores the values String values = deciFormat.getCurrency() .getDisplayName(); // Prints the currency System.out.println(values); } } Output: Canadian Dollar Reference: https://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html#getCurrency() Comment More infoAdvertise with us Next Article DecimalFormat getCurrency() method in Java G gopaldave Follow Improve Article Tags : Java Java-Functions Java-text package Java-DecimalFormat Practice Tags : Java Similar Reads DecimalFormat getMultiplier() method in Java The getMultiplier() method is a built-in method of the java.text.DecimalFomrat class in Java and is used to get the multiplier to be used in different formats like, percentage, percentile etc. Syntax: public int getMultiplier() Parameters: The function does not accepts any parameter. Return Value: T 1 min read DecimalFormat equals() method in Java The equals() method is a built-in method of the java.text.DecimalFormat class accepts an argument which is an object and returns true if this argument object is same as the object, else it returns false. Syntax: public boolean equals(Object arg) Parameters: The function accepts a single mandatory pa 2 min read DecimalFormat hashCode() method in Java The hashCode() method is a built-in method of the java.text.DecimalFomrat class in Java and is used to get an integral hashCode value for this DecimalFormat instance. Syntax: public int hashCode() Parameters: The function does not accepts any parameter. Return Value: The function returns an integral 1 min read DecimalFormat getRoundingMode() method in Java The getRoundingMode() method is a built-in method of the java.text.DecimalFomrat class in Java and is used to get the rounding mode used to round the numbers in this DecimalFormat instance. Syntax: public RoundingMode getRoundingMode() Parameters: The function does not accepts any parameter. Return 1 min read DecimalFormat getGroupingSize() method in Java The getGroupingSize() method is a built-in method of the java.text.DecimalFomrat class in Java and is used to get the grouping size for this DecimalFormat instance. The grouping size is defined as the number of digits present between grouping separators in the integer portion of a number. For exampl 1 min read Like