Java DecimalFormat getDecimalFormatSymbols()方法
getDecimalFormatSymbols() 方法是Java中 java.text.DecimalFomrat 类的一个内置方法,用于获取该DecimalFormat实例的十进制格式符号的副本。这些符号是固定的,不会被用户改变。
语法:
public DecimalFormatSymbols getDecimalFormatSymbols()
参数 :该函数不接受任何参数。
返回值 :该函数返回该DecimalFormat实例的DecimalFomratSymbols的副本。
下面是上述函数的实现。
程序1 :
// Java program to illustrate the// getDecimalFormatSymbols() method import java.text.DecimalFormat;import java.util.Currency;import java.util.Locale; public class Main { public static void main(String[] args) { // Get the DecimalFormat Instance DecimalFormat deciFormat = new DecimalFormat(); // Print the DecimalFormatSymbols System.out.println(deciFormat.getDecimalFormatSymbols()); }}
输出
java.text.DecimalFormatSymbols@1073a
程序2 :
// Java program to illustrate the// getDecimalFormatSymbols() 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)); // Print the DecimalFormatSymbols System.out.println(deciFormat.getDecimalFormatSymbols()); }}输出
java.text.DecimalFormatSymbols@1073a
参考资料 : https://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html#getDecimalFormatSymbols()
