The toPattern() method of java.text.MessageFormat class is used to get string representation of the current pattern of this message format object.
Syntax: 
 
public String toPattern()
Parameter: This method does not take any argument as a parameter.
Return Value: This method returns string representation of the current pattern of this message format object.
Below are the examples to illustrate the toPattern() method:
Example 1: 
 
Java
| // Java program to demonstrate// toPattern() methodimportjava.text.*;importjava.util.*;importjava.io.*;publicclassGFG {    publicstaticvoidmain(String[] argv)    {        // creating and initializing  MessageFormat        MessageFormat mf            = newMessageFormat("{0, number, #}, {2, date, #.#}, {4, time}");        // getting the pattern        // of this MessageFormat Object        // using toPattern() method        String patt = mf.toPattern();        // display the result        System.out.println("current pattern of MessageFormat Object : "+ patt);    }} | 
current pattern of MessageFormat Object : {0, number, #}, {2, date, #.#}, {4, time}
Example 2: 
 
Java
| // Java program to demonstrate// toPattern() methodimportjava.text.*;importjava.util.*;importjava.io.*;publicclassGFG {    publicstaticvoidmain(String[] argv)    {        // creating and initializing  MessageFormat        MessageFormat mf            = newMessageFormat("{0, number, #}, {4, time}");        // getting the pattern        // of this MessageFormat Object        // using toPattern() method        String patt = mf.toPattern();        // display the result        System.out.println("current pattern of MessageFormat Object : "+ patt);    }} | 
current pattern of MessageFormat Object : {0, number, #}, {4, time}
Reference: https://docs.oracle.com/javase/9/docs/api/java/text/MessageFormat.html#toPattern–
 


 
                                    







