Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

DateTimeFormatInfo.GetAllDateTimePatterns Method (Char)

Returns all the patterns in which date and time values can be formatted using the specified standard format string.

Namespace:  System.Globalization
Assembly:  mscorlib (in mscorlib.dll)
member GetAllDateTimePatterns : 
        format:char -> string[] 

Parameters

format
Type: System.Char

A standard format string.

Return Value

Type: System.String[]
An array containing the standard patterns in which date and time values can be formatted using the specified format string.
ExceptionCondition
ArgumentException

format is not a valid standard format string.

This method returns an array containing the custom format strings that correspond to a particular standard format string. See Standard Date and Time Format Strings for a list of the standard format strings.

You can use the custom format strings in the array returned by the GetAllDateTimePatterns method in formatting operations. However, if you do, the string representation of a date and time value returned in that formatting operation cannot always be parsed successfully by the Parse and TryParse methods. Therefore, you cannot assume that the custom format strings returned by the GetAllDateTimePatterns method can be used to round-trip date and time values. The following example illustrates this problem. It retrieves a DateTimeFormatInfo object that contains formatting information for the Russia (Russian) culture. It calls the GetAllDateTimePatterns(Char) method for each standard format string, and then passes each custom format string in the returned array to the DateTime.ToString(String) method to create the string representation of a date and time. This example then attempts to parse this value by calling the DateTime.TryParse(String, DateTime) method. As the output from the example shows, some of the custom format strings do not produce a date and time value that successfully round-trips.

No code example is currently available or this language may not be supported.

To parse the string representation of a date and time that can be expressed in a number of predefined custom formats, call one of the following methods:

The custom format strings in the array returned by the GetAllDateTimePatterns method depends on the current calendar of the culture for which the DateTimeFormatInfo object supplies formatting information. If the calendar changes, the array returned by this method also changes.

The following example displays the date and time patterns for the current calendar.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.