DateTimeFormatInfo.Calendar Property
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Gets or sets the calendar to use for the current culture.
Assembly: mscorlib (in mscorlib.dll)
Property Value
Type: System.Globalization.CalendarThe Calendar indicating the calendar to use for the current culture. The default for InvariantInfo is the GregorianCalendar.
| Exception | Condition |
|---|---|
| ArgumentNullException | An attempt was made to set the property to Nothing. |
| ArgumentOutOfRangeException | An attempt was made to set the property to a Calendar that is not valid for the current culture. |
| InvalidOperationException | The DateTimeFormatInfo object is read-only. |
The Calendar property accepts only calendars that are valid for the culture associated with this instance of DateTimeFormatInfo. Valid cultures are defined by the CultureInfo.OptionalCalendars property array. For example, if the current instance originated from the DateTimeFormat property of an "en-US" CultureInfo object, this property can accept only the calendars that are valid for the "en-US" culture.
Changing the value of this property affects the following properties as well: MonthNames, AbbreviatedMonthNames, DayNames, AbbreviatedDayNames, CalendarWeekRule, FirstDayOfWeek, FullDateTimePattern, LongDatePattern, ShortDatePattern, YearMonthPattern, and MonthDayPattern.
For example, if the culture of the current thread is Japanese, this property accepts JapaneseCalendar, LocalizedGregorianCalendar, or USEnglishGregorianCalendar. When the JapaneseCalendar is used, the default long date specifier is "gg y'\x5e74'M'\x6708'd'\x65e5'". When the LocalizedGregorianCalendar, is used, the default long date specifier is "yyyy'\x5e74'M'\x6708'd'\x65e5'".