Java LocalDate类| 带示例的getEra()方法
LocalDate类的getEra()方法 (LocalDate Class getEra() method)
getEra() method is available in java.time package.
getEra()方法在java.time包中可用。
getEra() method is used to get the era applicable for this LocalDate object.
getEra()方法用于获取适用于此LocalDate对象的时代。
getEra() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.
getEra()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。
getEra() method does not throw an exception at the time of getting era.
getEra()方法在获取时代时不会引发异常。
Syntax:
句法:
public Era getEra();Parameter(s):
参数:
None
没有
Return value:
返回值:
The return type of this method is Era, it returns the Era at this object based on ISO.
此方法的返回类型为Era ,它根据ISO返回此对象处的Era。
Example:
例:
// Java program to demonstrate the example // of Era getEra() method of LocalDateimport java.time.*; import java.time.chrono.*;public class GetEraOfLocalDate {public static void main(String args[]) {// Instantiates two LocalDateLocalDate l_da1 = LocalDate.parse("2007-04-05");LocalDate l_da2 = LocalDate.of(-2008, Month.MAY, 10);// Display l_da1,l_da2System.out.println("LocalDate l_da1 and l_da2: ");System.out.println("l_da1: " + l_da1);System.out.println("l_da2: " + l_da2);System.out.println();// Here, this method returns the era// applicable at this date l_da1Era get_era = l_da1.getEra();// Display get_eraSystem.out.println("l_da1.getEra(): " + get_era);// Here, this method returns the era// applicable at this date l_da2get_era = l_da2.getEra();// Display get_eraSystem.out.println("l_da2.getEra(): " + get_era);} }Output
输出量
LocalDate l_da1 and l_da2: l_da1: 2007-04-05 l_da2: -2008-05-10l_da1.getEra(): CE l_da2.getEra(): BCE翻译自: https://www.includehelp.com/java/localdate-getera-method-with-example.aspx
总结
以上是生活随笔为你收集整理的Java LocalDate类| 带示例的getEra()方法的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: java中为按钮添加图片_如何在Java
- 下一篇: Java FilterInputStre