Convert DateTime to all the string supported by the specified standard date and time format specifier and culture in CSharp
Description
The following code shows how to convert DateTime to all the string supported by the specified standard date and time format specifier and culture.
Example
/*from w ww. j ava 2 s. c om*/
using System;
public class MainClass{
public static void Main(String[] argv){
DateTime july28 = new DateTime(2009, 7, 28, 5, 23, 15);
IFormatProvider culture =
new System.Globalization.CultureInfo("fr-FR", true);
// Get the short date formats using the "fr-FR" culture.
string [] frenchJuly28Formats =
july28.GetDateTimeFormats('d', culture);
// Display july28 in short date formats using "fr-FR" culture.
foreach (string format in frenchJuly28Formats) {
System.Console.WriteLine(format);
}
}
}
The code above generates the following result.