System.Globalization.DateTimeFormatInfo.LongDatePattern Property

Gets or sets the custom format string for a long date value.

Syntax

public string LongDatePattern { get; set; }

Value

A string containing the format pattern for a long date value.

Exceptions

TypeReason
ArgumentNullExceptionThe value specified for a set operation is a null reference.
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Remarks

The DateTimeFormatInfo.LongDatePattern property defines the culture-specific format of date strings that are returned by calls to the DateTime.ToString and DateTimeOffset.ToString methods and by composite format strings that are supplied the "D" standard format string. The following example illustrates the relationships among the following: the "D" standard format string, the custom format string returned by the DateTimeFormatInfo.LongDatePattern property, and the culture-specific representation of a date.

code reference: System.Globalization.DateTimeFormatInfo.LongDatePattern#2

See Custom Date and Time Format Strings for individual custom format specifiers that can be combined to construct custom format strings such as "dddd, dd MMMM yyyy".

You should set the date separator in the long date pattern to an exact string instead of using the date separator placeholder. For example, to obtain the pattern MM-DD-yyyy, set the long date pattern to "MM-DD-yyyy".

The value of this property may change if the calendar used by a culture changes. For instance, the following example shows how theDateTimeFormatInfo.LongDatePattern property of a System.Globalization.CultureInfo object that represents the Arabic (Syria) culture changes when the System.Globalization.Calendar object used by the culture changes.

code reference: System.Globalization.DateTimeFormatInfo.LongDatePattern#3

Requirements

Namespace: System.Globalization
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0