Calendar.ToFourDigitYear(Int32) Método
Definição
Converte o ano especificado em um ano de quatro dígitos usando a propriedade TwoDigitYearMax para determinar o século apropriado.Converts the specified year to a four-digit year by using the TwoDigitYearMax property to determine the appropriate century.
public:
virtual int ToFourDigitYear(int year);
public virtual int ToFourDigitYear (int year);
abstract member ToFourDigitYear : int -> int
override this.ToFourDigitYear : int -> int
Public Overridable Function ToFourDigitYear (year As Integer) As Integer
Parâmetros
- year
- Int32
Um inteiro de dois ou quatro dígitos que representa o ano a ser convertido.A two-digit or four-digit integer that represents the year to convert.
Retornos
Um inteiro que contém a representação de quatro dígitos de year.An integer that contains the four-digit representation of year.
Exceções
year está fora do intervalo com suporte do calendário.year is outside the range supported by the calendar.
Comentários
TwoDigitYearMax é o último ano no intervalo de 100 anos que pode ser representado por um ano de dois dígitos.TwoDigitYearMax is the last year in the 100-year range that can be represented by a two-digit year. O século é determinado encontrando a única ocorrência do dois dígitos year dentro desse intervalo de 100 anos.The century is determined by finding the sole occurrence of the two-digit year within that 100-year range. Por exemplo, se TwoDigitYearMax for definido como 2029, o intervalo de 100 anos será de 1930 a 2029.For example, if TwoDigitYearMax is set to 2029, the 100-year range is from 1930 to 2029. Portanto, um valor de 2 dígitos de 30 é interpretado como 1930, enquanto um valor de 2 dígitos de 29 é interpretado como 2029.Therefore, a 2-digit value of 30 is interpreted as 1930, while a 2-digit value of 29 is interpreted as 2029.
Se year for maior ou igual a 100, o valor de year será retornado inalterado.If year is greater than or equal to 100, the value of year is returned unchanged.
ToFourDigitYear o dá suporte a um ano de dois dígitos ou a um ano de quatro dígitos.ToFourDigitYear supports either a two-digit year or a four-digit year. Passar um valor de ano de dois dígitos (menor que 100) faz com que o método converta o valor em um valor de quatro dígitos de acordo com o TwoDigitYearMax valor que representa o século apropriado.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. Se o aplicativo fornecer um valor de ano de quatro dígitos que esteja dentro do intervalo de calendário com suporte para ToFourDigitYear , o método retornará o valor de entrada real.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. Se o aplicativo fornecer um valor de quatro dígitos que está fora do intervalo de calendário com suporte, ou se ele fornecer um valor negativo, o método lançará uma exceção.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.