Calendar.TwoDigitYearMax Property

Definition

获取或设置可以用两位数年份表示的 100 年范围内的最后一年。Gets or sets the last year of a 100-year range that can be represented by a 2-digit year.

public:
 virtual property int TwoDigitYearMax { int get(); void set(int value); };
public virtual int TwoDigitYearMax { get; set; }
member this.TwoDigitYearMax : int with get, set
Public Overridable Property TwoDigitYearMax As Integer

Property Value

Int32

可以用两位数年份表示的 100 年范围内的最后一年。The last year of a 100-year range that can be represented by a 2-digit year.

Exceptions

当前 Calendar 对象为只读。The current Calendar object is read-only.

Remarks

此属性允许将两位数的年份正确翻译为四位数年份。This property allows a 2-digit year to be properly translated to a 4-digit year. 例如,如果将此属性设置为2029,则100年范围是从1930到2029。For example, if this property is set to 2029, the 100-year range is from 1930 to 2029. 因此,两位数值30被解释为1930,而两位数字的值29则解释为2029。Therefore, a 2-digit value of 30 is interpreted as 1930, while a 2-digit value of 29 is interpreted as 2029.

此属性的初始值派生自控制面板的 "区域和语言选项" 部分中的设置。The initial value of this property is derived from the settings in the regional and language options portion of Control Panel. 但是,在 AppDomain的生命周期内,该信息可能会更改。However, that information can change during the life of the AppDomain. Calendar 类不会自动检测系统设置中的更改。The Calendar class does not detect changes in the system settings automatically. 如果 "区域和语言" 选项中不支持日历,则此属性的初始值是 Calendar 类定义的默认值。If the calendar is not supported in the regional and language options, the initial value of this property is the default value defined by the Calendar class.

您的应用程序应将此值设置为99,以指示要按字面取的两位数年份。Your application should set this value to 99 to indicate that 2-digit years are to be taken literally. 例如,如果将此属性设置为99,则100年的范围是从0(对于大多数日历而言不是有效的值)到99。For example, if this property is set to 99, the 100-year range is from 0 (not a valid value for most calendars) to 99. 因此,两位数值30被解释为30。Therefore, a 2-digit value of 30 is interpreted as 30.

Applies to

See also