Format a DateTime with Long Date Pattern in CSharp
Description
The following code shows how to format a DateTime with Long Date Pattern.
Example
using System;// w w w .ja va 2s.co m
using System.Globalization;
public class Example
{
public static void Main()
{
DateTime date1 = new DateTime(2010, 6, 30);
Console.WriteLine("D Format Specifier: {0:D}", date1);
string longPattern = CultureInfo.CurrentCulture.DateTimeFormat.LongDatePattern;
Console.WriteLine("'{0}' custom format string: {1}",
longPattern, date1.ToString(longPattern));
}
}
The code above generates the following result.