DateTime.GetDateTimeFormats Method (Char)
Assembly: mscorlib (in mscorlib.dll)
public String[] GetDateTimeFormats ( char format )
public function GetDateTimeFormats ( format : char ) : String[]
Parameters
- format
A Unicode character containing a format specifier.
Return Value
A string array where each element is the representation of the value of this instance formatted with the format standard DateTime formatting specifier.Each element of the return value is formatted using information from the current culture. For more information about culture-specific formatting information for the current culture, see CultureInfo.CurrentCulture.
For more information about the standard formatting specifiers, see System.Globalization.DateTimeFormatInfo.
The following code example demonstrates the GetDateTimeFormats method.
DateTime july28 = DateTime(1979,7,28,5,23,15,16); array<String^>^july28Formats = july28.GetDateTimeFormats(); // Print [Out] july28* in all DateTime formats using the // default culture. System::Collections::IEnumerator^ myEnum = july28Formats->GetEnumerator(); while ( myEnum->MoveNext() ) { String^ format = safe_cast<String^>(myEnum->Current); System::Console::WriteLine( format ); } IFormatProvider^ culture = gcnew System::Globalization::CultureInfo( "fr-FR",true ); // Get the short date formats using the S"fr-FR" culture. array<String^>^frenchJuly28Formats = july28.GetDateTimeFormats( 'd', culture ); // Print [Out] july28* in various formats using S"fr-FR" culture. System::Console::WriteLine( "Starting fr-FR formats" ); System::Collections::IEnumerator^ myEnum2 = frenchJuly28Formats->GetEnumerator(); while ( myEnum2->MoveNext() ) { String^ format = safe_cast<String^>(myEnum2->Current); System::Console::WriteLine( format ); } } /* This example produces the following results: Is Thursday the day of the week for 5/1/2003?: True The day of the week for 5/1/2003 is Thursday. */
DateTime july28 = new DateTime(1979, 7, 28, 5, 23, 15, 16);
String july28Formats[] = july28.GetDateTimeFormats();
// Print out july28 in all DateTime formats using the
// default culture.
for (int iCtr1 = 0; iCtr1 < july28Formats.get_Length(); iCtr1++) {
String format = july28Formats[iCtr1];
System.Console.WriteLine(format);
}
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);
// Print out july28 in various formats using "fr-FR" culture.
System.Console.WriteLine("Starting fr-FR formats");
for (int iCtr2 = 0; iCtr2 < frenchJuly28Formats.get_Length(); iCtr2++) {
String format = frenchJuly28Formats[iCtr2];
System.Console.WriteLine(format);
}
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.