DateTime::GetDateTimeFormats Method (IFormatProvider)
Updated: January 2010
Converts the value of this instance to all the string representations supported by the standard date and time format specifiers and the specified culture-specific formatting information.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- provider
- Type: System::IFormatProvider
An object that supplies culture-specific formatting information about this instance.
Return Value
Type: array<System::String>A string array where each element is the representation of the value of this instance formatted with one of the standard date and time format specifiers.
The string array returned by the DateTime::GetDateTimeFormats(IFormatProvider) method is equivalent to combining the string arrays returned by separate calls to the DateTime::GetDateTimeFormats(Char, IFormatProvider) method with the "d", "D", "f", "F", "g", "G", "m", "o", "r", "s", "t", "T", "u", "U", and "y" standard format strings. For more information about standard format specifiers, see Standard Date and Time Format Strings.
Each element of the return value is formatted using culture-specific information supplied by provider.
Note: |
|---|
Because this method uses culture-sensitive data, your application should not assume that multiple calls to the method will return identical data unless provider is a CultureInfo object that represents the invariant culture. The data returned by this method can change if the user overrides the individual cultural settings of provider or if an update occurs to the system's cultural data for provider. |
The following example demonstrates the DateTime::GetDateTimeFormats(IFormatProvider) method. It displays the string representation of a date using all possible standard date and time formats for the fr-FR culture.
DateTime juil28 = DateTime(2009, 7, 28, 5, 23, 15, 16); IFormatProvider^ culture = gcnew System::Globalization::CultureInfo("fr-FR", true ); // Get the short date formats using the S"fr-FR" culture. array<String^>^frenchJuly28Formats = juil28.GetDateTimeFormats(culture ); // Print [Out] july28* in all DateTime formats using fr-FR culture. System::Collections::IEnumerator^ myEnum2 = frenchJuly28Formats->GetEnumerator(); while ( myEnum2->MoveNext() ) { String^ format = safe_cast<String^>(myEnum2->Current); System::Console::WriteLine(format ); }
The example displays the following output:
28/07/2009 28/07/09 28.07.09 28-07-09 2009-07-28 mardi 28 juillet 2009 28 juil. 09 28 juillet 2009 mardi 28 juillet 2009 05:23 mardi 28 juillet 2009 5:23 mardi 28 juillet 2009 05.23 mardi 28 juillet 2009 05 h 23 28 juil. 09 05:23 28 juil. 09 5:23 28 juil. 09 05.23 28 juil. 09 05 h 23 28 juillet 2009 05:23 28 juillet 2009 5:23 28 juillet 2009 05.23 28 juillet 2009 05 h 23 mardi 28 juillet 2009 05:23:15 mardi 28 juillet 2009 5:23:15 mardi 28 juillet 2009 05.23 mardi 28 juillet 2009 05 h 23 28 juil. 09 05:23:15 28 juil. 09 5:23:15 28 juil. 09 05.23 28 juil. 09 05 h 23 28 juillet 2009 05:23:15 28 juillet 2009 5:23:15 28 juillet 2009 05.23 28 juillet 2009 05 h 23 28/07/2009 05:23 28/07/2009 5:23 28/07/2009 05.23 28/07/2009 05 h 23 28/07/09 05:23 28/07/09 5:23 28/07/09 05.23 28/07/09 05 h 23 28.07.09 05:23 28.07.09 5:23 28.07.09 05.23 28.07.09 05 h 23 28-07-09 05:23 28-07-09 5:23 28-07-09 05.23 28-07-09 05 h 23 2009-07-28 05:23 2009-07-28 5:23 2009-07-28 05.23 2009-07-28 05 h 23 28/07/2009 05:23:15 28/07/2009 5:23:15 28/07/2009 05.23 28/07/2009 05 h 23 28/07/09 05:23:15 28/07/09 5:23:15 28/07/09 05.23 28/07/09 05 h 23 28.07.09 05:23:15 28.07.09 5:23:15 28.07.09 05.23 28.07.09 05 h 23 28-07-09 05:23:15 28-07-09 5:23:15 28-07-09 05.23 28-07-09 05 h 23 2009-07-28 05:23:15 2009-07-28 5:23:15 2009-07-28 05.23 2009-07-28 05 h 23 28 juillet 28 juillet 2009-07-28T05:23:15.0160000 2009-07-28T05:23:15.0160000 Tue, 28 Jul 2009 05:23:15 GMT Tue, 28 Jul 2009 05:23:15 GMT 2009-07-28T05:23:15 05:23 5:23 05.23 05 h 23 05:23:15 5:23:15 05.23 05 h 23 2009-07-28 05:23:15Z mardi 28 juillet 2009 12:23:15 mardi 28 juillet 2009 12:23:15 mardi 28 juillet 2009 12.23 mardi 28 juillet 2009 12 h 23 28 juil. 09 12:23:15 28 juil. 09 12:23:15 28 juil. 09 12.23 28 juil. 09 12 h 23 28 juillet 2009 12:23:15 28 juillet 2009 12:23:15 28 juillet 2009 12.23 28 juillet 2009 12 h 23 juillet 2009 juillet 2009
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note: