📌  相关文章
📜  Java中的 JapaneseChronology getCalendarType() 方法与示例

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

Java中的 JapaneseChronology getCalendarType() 方法与示例

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

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
        // JapaneseDate Object
        JapaneseDate hidate
            = JapaneseDate.now();
 
        // getting JapaneseChronology
        // used in JapaneseDate
        JapaneseChronology 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);
    }
}


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
        // JapaneseDate Object
        JapaneseDate hidate
            = JapaneseDate.now(
                Clock.systemDefaultZone());
 
        // getting JapaneseChronology
        // used in JapaneseDate
        JapaneseChronology 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);
    }
}


输出
Type of Calendar : japanese

示例 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
        // JapaneseDate Object
        JapaneseDate hidate
            = JapaneseDate.now(
                Clock.systemDefaultZone());
 
        // getting JapaneseChronology
        // used in JapaneseDate
        JapaneseChronology 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);
    }
}
输出
Type of Calendar : japanese

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