DateTimeFormatInfo.GetEraName(Int32) 方法

定義

傳回含有指定紀元名稱的字串。Returns the string containing the name of the specified era.

public:
 System::String ^ GetEraName(int era);
public string GetEraName (int era);
member this.GetEraName : int -> string
Public Function GetEraName (era As Integer) As String

參數

era
Int32

表示紀元的整數。The integer representing the era.

傳回

含有紀元名稱的字串。A string containing the name of the era.

例外狀況

era 不表示 Calendar 屬性所指定曆法的有效紀元。era does not represent a valid era in the calendar specified in the Calendar property.

備註

紀元名稱是行事曆用來參考從固定點或事件全盛時期來勢洶洶之時間週期的名稱。The era name is the name a calendar uses to refer to a period of time reckoned from a fixed point or event. 例如,「西元」For example, "A.D." 或「西元」or "C.E." 是西曆中目前的紀元。is the current era in the Gregorian calendar.

的有效值era會列Eras在衍生自之Calendar適當類別的屬性中。The valid values for era are listed in the Eras property of the appropriate class derived from Calendar. 例如: JapaneseCalendar.Eras顯示此實作為支援的紀元清單。For example: JapaneseCalendar.Eras displays a list of eras that are supported by this implementation.

重要

日本曆法的紀元是以天皇的統治為基礎,因此有變更是正常的。Eras in the Japanese calendars are based on the emperor's reign and are therefore expected to change. 例如,2019 年 5 月 1 日之後,JapaneseCalendarJapaneseLunisolarCalendar 中將開始使用「令和」。For example, May 1, 2019 marked the beginning of the Reiwa era in the JapaneseCalendar and JapaneseLunisolarCalendar. 此變更對使用這些日曆的所有應用程式都有影響。Such a change of era affects all applications that use these calendars. 若要取得詳細資訊及判斷您的應用程式是否受影響,請參閱 Handling a new era in the Japanese calendar in .NET (處理 .NET 中日本日曆的新紀元)。See Handling a new era in the Japanese calendar in .NET for more information and to determine whether your applications are affected. 若要了解如何在 Windows 系統上測試您的應用程式,確保其已準備好面對紀元變更,請參閱 Prepare your application for the Japanese era change (讓應用程式準備好因應日本紀元變更)。See Prepare your application for the Japanese era change for information on testing your applications on Windows systems to ensure their readiness for the era change. 請參閱使用紀年以了解 .NET 中支援使用多種紀年的日曆,以及在處理支援多種紀年的日曆時能採用最佳做法。See Working with eras for features in .NET that support calendars with multiple eras and for best practices when working with calendars that support multiple eras.

給呼叫者的注意事項

如果行事曆是以表示TaiwanCalendarCurrentCulture但不是 "zh-臺灣",則NativeCalendarNameGetEraName(Int32)GetAbbreviatedEraName(Int32)會傳回空字串("")。If the calendar is represented by TaiwanCalendar but the CurrentCulture is not "zh-TW", then NativeCalendarName, GetEraName(Int32), and GetAbbreviatedEraName(Int32) return an empty string ("").

適用於

另請參閱