KoreanCalendar.ToFourDigitYear(Int32) Method

Definition

使用 TwoDigitYearMax 属性将指定的年份转换为四位数年份,以确定相应的纪元。Converts the specified year to a four-digit year by using the TwoDigitYearMax property to determine the appropriate century.

public:
 override int ToFourDigitYear(int year);
public override int ToFourDigitYear (int year);
override this.ToFourDigitYear : int -> int
Public Overrides Function ToFourDigitYear (year As Integer) As Integer

Parameters

year
Int32

一个两位数或四位数的整数,用于表示要转换的年份。A two-digit or four-digit integer that represents the year to convert.

Returns

Int32

包含 year 的四位数表示形式的整数。An integer that contains the four-digit representation of year.

Exceptions

year 超出了日历支持的范围。year is outside the range supported by the calendar.

Remarks

TwoDigitYearMax 在100年内定义可由 ToFourDigitYear表示的最后一年。TwoDigitYearMax defines the last year in the 100-year range that can be represented by ToFourDigitYear. 通过在该100年范围内查找两位数年份的唯一匹配项来确定纪元。The century is determined by finding the sole occurrence of the two-digit year within that 100-year range. 例如,如果 TwoDigitYearMax 设置为2029,则100年范围是从1930到2029。For example, if TwoDigitYearMax is set to 2029, the 100-year range is from 1930 to 2029. 因此,两位数值30被解释为1930,而两位数字的值29则解释为2029。Therefore, a two-digit value of 30 is interpreted as 1930, while a two-digit value of 29 is interpreted as 2029.

ToFourDigitYear 支持两位数年份或四位数年份。ToFourDigitYear supports either a two-digit year or a four-digit year. 如果传递了一个两位数的年份值(小于100),则会使方法根据表示相应世纪的 TwoDigitYearMax 值将值转换为四位值。Passing a two-digit year value (less than 100) causes the method to convert the value to a four-digit value according to the TwoDigitYearMax value representing the appropriate century. 如果应用程序提供了一个四位数的年份值,该范围在支持的日历范围内以 ToFourDigitYear,则该方法将返回实际输入值。If the application supplies a four-digit year value that is within the supported calendar range to ToFourDigitYear, the method returns the actual input value. 如果应用程序提供了一个在支持的日历范围之外的四位数值,或者如果它提供负值,则该方法将引发异常。If the application supplies a four-digit value that is outside the supported calendar range, or if it supplies a negative value, the method throws an exception.

Applies to

See also