Edit

Share via


DateTimeFormatInfo.GetEraName(Int32) Method

Definition

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

Parameters

era
Int32

The integer representing the era.

Returns

A string containing the name of the era.

Exceptions

era does not represent a valid era in the calendar specified in the Calendar property.

Remarks

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.

The valid values for era are listed in the Eras property of the appropriate class derived from Calendar. For example: JapaneseCalendar.Eras displays a list of eras that are supported by this implementation.

Important

Eras in the Japanese calendars are based on the emperor's reign and are therefore expected to change. 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. For more information and to determine whether your applications are affected, see Handling a new era in the Japanese calendar in .NET. For information on testing your applications on Windows systems to ensure their readiness for the era change, see Prepare your application for the Japanese era change. For features in .NET that support calendars with multiple eras and for best practices when working with calendars that support multiple eras, see Working with eras.

Notes to Callers

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 ("").

Applies to

See also