Java DecimalStyle withZeroDigit()方法及实例

Java DecimalStyle withZeroDigit()方法及实例

Java中 java.time.format.DecimalStyle类withZeroDigit() 方法用于设置该DecimalStyle的Locale中用于表示0的字符。该方法以该字符为参数,并返回带有最新负号字符的DecimalStyle实例。

语法。

public void withZeroDigit(char zeroDigit)
Java

参数。该方法接受 zeroDigit 作为参数,它是该DecimalStyle中用来代表零的字符。

返回值。该方法返回带有最新负号字符的DecimalStyle实例。

异常。此方法不抛出任何异常。

程序。

// Java program to demonstrate
// the above method
  
import java.time.format.*;
import java.util.*;
  
public class DecimalStyleDemo {
    public static void main(String[] args)
    {
  
        DecimalStyle ds
            = DecimalStyle.STANDARD;
  
        System.out.println("Current Character"
                           + " used for zero: "
                           + ds.getZeroDigit());
  
        char zeroDigit = '*';
  
        ds = ds.withZeroDigit(zeroDigit);
  
        System.out.println("Updated Character "
                           + "used for zero: "
                           + ds.getZeroDigit());
    }
}
Java

输出:

Current Character used for zero: 0
Updated Character used for zero: *
Java

参考资料: https://docs.oracle.com/javase/10/docs/api/java/time/format/DecimalStyle.html#withZeroDigit(char)

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程

登录

注册