Export (0) Print
Expand All

DateTimeFormatInfo.Calendar Property

Gets or sets the calendar to use for the current culture.

Namespace:  System.Globalization
Assemblies:   System.Globalization (in System.Globalization.dll)
  mscorlib (in mscorlib.dll)

public Calendar Calendar { get; set; }

Property Value

Type: System.Globalization.Calendar
The calendar to use for the current culture. The default for InvariantInfo is a GregorianCalendar object.


The property is being set to null.


The property is being set to a Calendar object that is not valid for the current culture.


The property is being set and the DateTimeFormatInfo object is read-only.

The Calendar property accepts only calendars that are valid for the culture that is associated with the DateTimeFormatInfo object. The CultureInfo.OptionalCalendars property specifies the calendars that can be used by a particular culture, and the CultureInfo.Calendar property specifies the default calendar for the 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, Localized GregorianCalendar, or USEnglish GregorianCalendar. When the JapaneseCalendar is used, the default long date specifier is "gg y'\x5e74'M'\x6708'd'\x65e5'". When the Localized GregorianCalendar, is used, the default long date specifier is "yyyy'\x5e74'M'\x6708'd'\x65e5'".

The following example defines a ChangeCalendar method that changes a culture's current calendar to a specified calendar unless it is already the current calendar or if it is not supported by the culture. The code that calls the method instantiates a CultureInfo object that represents the Arabic (Egypt) culture and first attempts to change its calendar to the Japanese calendar. Because the Japanese calendar is not supported, the method makes not change the culture's calendar. However, because the Umm al-Qura calendar is a member of the CultureInfo.OptionalCalendars collection, the method does succeed in making it the current calendar for the ar-EG culture.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft