DateTime.GetDateTimeFormats Method (Char, IFormatProvider)

July 28, 2014

Converts the value of this instance to all the string representations supported by the specified standard date and time format specifier and culture-specific formatting information.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

public string[] GetDateTimeFormats(
	char format,
	IFormatProvider provider
)

Parameters

format
Type: System.Char
A date and time format string (see Remarks).
provider
Type: System.IFormatProvider
An object that supplies culture-specific formatting information about this instance.

Return Value

Type: 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.

ExceptionCondition
FormatException

format is not a valid standard date and time format specifier character.

The format parameter can be any of the standard date and time format specifiers. These include d, D, f, F, g, G, M (or m), O (or o), R (or r), s, t, T, u, U, and Y (or y).

Each element of the return value is formatted using culture-specific information supplied by provider.

Important noteImportant Note:

Because this method uses culture-sensitive data, you 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 GetDateTimeFormats(Char, IFormatProvider) method. It displays the string representations of a date using the short date format specifier ("d") for the fr-FR culture.

Windows Phone OS

Supported in: 8.1, 8.0

Show:
© 2014 Microsoft