📌  相关文章
📜  Java中的 MinguoChronology getId() 方法示例

📅  最后修改于: 2022-05-13 01:55:06.778000             🧑  作者: Mango

Java中的 MinguoChronology getId() 方法示例

Java.time.chrono.MinguoChronology类的getId()方法用于检索取消 getId() 方法的特定年表的标识状态。

句法:

public String getId()

参数:此方法不接受任何参数作为参数。

返回值:此方法返回 getId() 方法被撤销的特定年表的标识状态。

以下是说明getId()方法的示例:

示例 1:

// Java program to demonstrate
// getId() method
  
import java.util.*;
import java.io.*;
import java.time.*;
import java.time.chrono.*;
  
public class GFG {
    public static void main(String[] argv)
    {
        // creating and initializing
        // MinguoDate Object
        MinguoDate hidate
            = MinguoDate.now();
  
        // getting MinguoChronology
        // used in MinguoDate
        MinguoChronology crono
            = hidate.getChronology();
  
        // getting id of this Chronology
        // by using getId() method
        String id = crono.getId();
  
        // display the result
        System.out.println("id : " + id);
    }
}
输出:
id : Minguo

示例 2:

// Java program to demonstrate
// getId() method
  
import java.util.*;
import java.io.*;
import java.time.*;
import java.time.chrono.*;
  
public class GFG {
    public static void main(String[] argv)
    {
        // creating and initializing
        // MinguoDate Object
        MinguoDate hidate
            = MinguoDate.now(Clock.systemDefaultZone());
  
        // getting MinguoChronology
        // used in MinguoDate
        MinguoChronology crono
            = hidate.getChronology();
  
        // getting id of this Chronology
        // by using getId() method
        String id = crono.getId();
  
        // display the result
        System.out.println("id : " + id);
    }
}
输出:
id : Minguo

参考: https://docs.oracle.com/javase/9/docs/api/ Java/time/chrono/MinguoChronology.html#getId–