System.Globalization.DateTimeFormatInfo.GetEra Method

Returns the integer representing the specified era.

Syntax

public int GetEra (string eraName)

Parameters

eraName
The string containing the name of the era.

Returns

The integer representing the era, if eraName is valid; otherwise, -1.

Exceptions

TypeReason
ArgumentNullException eraName is a null reference.

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 comparison with eraName is case-insensitive, for example, "A.D." is equivalent to "a.d.".

DateTimeFormatInfo.GetEra(string) ignores punctuation in abbreviated era names, only if the System.Globalization.GregorianCalendar is selected in DateTimeFormatInfo.Calendar and the culture uses "A.D." as the era name, that is, "A.D." is equivalent to "AD".

DateTimeFormatInfo.GetEra(string) compares eraName with the full era name returned by DateTimeFormatInfo.GetEraName(int) and with the abbreviated era name returned by DateTimeFormatInfo.GetAbbreviatedEraName(int).

Requirements

Namespace: System.Globalization
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0