ChoiceFormat applyPattern() method in Java with Examples
The applyPattern() method of java.text.ChoiceFormat class is used to set the new pattern text for current ChoiceFormat by overriding the current limit and format. This new pattern will be the combination of limit and format of ChoiceFormat
public void applyPattern(String newPattern)
Parameter: This method takes newPattern as parameter which is the new text pattern for ChoiceFormat.
Return Value: This method returns nothing.
Exception: This method throws NullPointerException if the specified newPattern is null.
Below are the examples to illustrate the applyPattern() method:
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.
current pattern : 1.0#sun|2.0#mon|3.0#tue new pattern : 4.0#wed|5.0#thu |6.0#fri |7.0#sat
current pattern : 1.0#sun|2.0#mon|3.0#tue String is Null Exception thrown : java.lang.NullPointerException