The applyLocalizedPattern() Method of DecimalFormat class in Java is used to apply a localized string pattern to this Decimal format. This pattern can be set by the user.
Syntax:
public void applyLocalizedPattern(String pattern)
Parameters: The method takes one parameter pattern of String type and refers to the pattern which will be used to format the DecimalPattern.
Return Value: The method returns void type.
Below programs illustrate the working of applyLocalizedPattern() Method:
Program 1:
// Java program to illustrate the // applyLocalizedPattern method import java.text.DecimalFormat; public class Main { public static void main(String[] args) { DecimalFormat deciFormat = new DecimalFormat(); deciFormat.applyLocalizedPattern("##, ##"); System.out.println(deciFormat.format(-123456789.54321)); } } |
-1, 23, 45, 67, 90
Program 2:
// Java program to illustrate the // applyLocalizedPattern method import java.text.DecimalFormat; public class Main { public static void main(String[] args) { DecimalFormat deciFormat = new DecimalFormat(); deciFormat.applyLocalizedPattern("#, #00.0#"); System.out.println(deciFormat.format(-123456789.54321)); } } |
-123, 456, 789.54
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- SimpleDateFormat applyLocalizedPattern() Method in Java with Examples
- DecimalFormat setCurrency() method in Java
- DecimalFormat setDecimalSeparatorAlwaysShown() method in Java
- DecimalFormat setMaximumFractionDigits() method in Java
- DecimalFormat setMaximumIntegerDigits() method in Java
- DecimalFormat hashCode() method in Java
- DecimalFormat setDecimalFormatSymbols() method in Java
- DecimalFormat setPositiveSuffix() method in Java
- DecimalFormat setMinimumIntegerDigits() method in Java
- DecimalFormat setMinimumFractionDigits() method in Java
- DecimalFormat setMultiplier() method in Java
- DecimalFormat setRoundingMode() method in Java
- DecimalFormat getRoundingMode() method in Java
- DecimalFormat getMultiplier() method in Java
- DecimalFormat getCurrency() method in Java
- DecimalFormat equals() method in Java
- DecimalFormat clone() method in Java
- DecimalFormat applyPattern() method in Java
- DecimalFormat setGroupingSize() method in Java
- DecimalFormat getDecimalFormatSymbols() method in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

