Java 中的 Minguo 年表 getCalendarType()方法,示例

原文:https://www . geeksforgeeks . org/minguoberythro-getcalendar type-method-in-Java-with-example/

Java . time . chrono . Minguo 年表类的 getCalendarType() 方法用于检索该 Minguo 年表系统下的日历类型。 语法:

public String getCalendarType()

参数:此方法不接受任何参数作为参数。 返回值:此方法返回的类型的日历位于此民国年表系统下。 以下是举例说明 getCalendarType() 方法: 例 1:

Java 语言(一种计算机语言,尤用于创建网站)

// Java program to demonstrate
// getCalendarType() 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 type of Calendar
        // by using getCalendarType() method
        String era = crono.getCalendarType();

        // display the result
        System.out.println("Type of Calendar : "
                           + era);
    }
}

Output

Type of Calendar : roc

例 2:

Java 语言(一种计算机语言,尤用于创建网站)

// Java program to demonstrate
// getCalendarType() 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 type of Calendar
        // by using getCalendarType() method
        String era = crono.getCalendarType();

        // display the result
        System.out.println("Type of Calendar : "
                           + era);
    }
}

Output

Type of Calendar : roc

参考:https://docs . Oracle . com/javase/9/docs/API/Java/time/chrono/Minguo 年表. html # getCalendarType–