JapaneseCalendar.ToFourDigitYear(Int32) JapaneseCalendar.ToFourDigitYear(Int32) JapaneseCalendar.ToFourDigitYear(Int32) JapaneseCalendar.ToFourDigitYear(Int32) Method

定义

使用 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

参数

year
Int32 Int32 Int32 Int32

一个表示要转换的年份的整数(通常为两位数)。An integer (usually two digits) that represents the year to convert.

返回

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

异常

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

注解

此方法实现 Calendar.ToFourDigitYearThis method implements Calendar.ToFourDigitYear.

由于日本日历中的年份通常小于四位数, 因此此实现始终返回year参数的值。Because the year in the Japanese calendar is typically less than four digits long, this implementation always returns the value of the year parameter.

ToFourDigitYear支持两位数年份或四位数年份。ToFourDigitYear supports either a two-digit year or a four-digit year. 但是, 有效年份通常表示为两位数 (小于 100)。However, a valid year is generally represented as two digits (less than 100). 如果传递两位数的年份值, 则该方法会根据TwoDigitYearMax表示相应世纪的值将值转换为四位数值。Passing a two-digit year value 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 value, or if it supplies zero or a negative value, ToFourDigitYear throws an exception.

适用于

另请参阅