DecimalFormat toLocalizedPattern() method in Java
Last Updated :
01 Apr, 2019
The toLocalizedPattern() method of the DecimalFormat class in Java is used to convert the format of the current pattern of this DecimalFormat to a localized string format. This converted localized string represents the pattern which is used to format the current state of this DecimalFormat instance.
Syntax:
public String toLocalizedPattern()
Parameters: This method does not accepts any parameter.
Return Value: This method returns a localized string which represents the pattern which is used to format the current state of this DecimalFormat instance.
Below programs illustrate the above method:
Program 1:
import java.text.DecimalFormat;
public class GFG {
public static void main(String[] args)
{
DecimalFormat deciFormat = new DecimalFormat();
String pattern = deciFormat.toLocalizedPattern();
System.out.println(pattern);
}
}
|
Program 2:
import java.text.DecimalFormat;
public class GFG {
public static void main(String[] args)
{
DecimalFormat deciFormat = new DecimalFormat();
deciFormat.applyPattern( "##, ##.##" );
String pattern = deciFormat.toLocalizedPattern();
System.out.println(pattern);
}
}
|
Output:
#, #0.## ;#, #0.##
Reference: https://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html#toLocalizedPattern()
Share your thoughts in the comments
Please Login to comment...