日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > java >内容正文

java

Java LocalDate类| 带示例的getEra()方法

發(fā)布時(shí)間:2025/3/11 java 47 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Java LocalDate类| 带示例的getEra()方法 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

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對(duì)象的時(shí)代。

  • 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()方法是一個(gè)非靜態(tài)方法,只能通過(guò)類對(duì)象訪問(wèn),如果嘗試使用類名稱訪問(wèn)該方法,則會(huì)收到錯(cuò)誤消息。

  • getEra() method does not throw an exception at the time of getting era.

    getEra()方法在獲取時(shí)代時(shí)不會(huì)引發(fā)異常。

Syntax:

句法:

public Era getEra();

Parameter(s):

參數(shù):

  • None

    沒(méi)有

Return value:

返回值:

The return type of this method is Era, it returns the Era at this object based on ISO.

此方法的返回類型為Era ,它根據(jù)ISO返回此對(duì)象處的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

總結(jié)

以上是生活随笔為你收集整理的Java LocalDate类| 带示例的getEra()方法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。