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 的有效值在从 Calendar派生的相应类的 Eras 属性中列出。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 系统上测试应用程序以确保针对元号更改的准备情况信息。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.

调用方说明

如果日历由 TaiwanCalendar 表示但 CurrentCulture 不是 "zh-chs",则 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 ("").

适用于

另请参阅