The DateTime..::.ParseExact(String, String, IFormatProvider) method parses the string representation of a date, which must be in the format defined by the format parameter. It also requires that the <Date> and <Time> elements of the string representation of a date and time appear in the order specified by format, and that s have no white space other than that permitted by format. If format defines a date with no time element and the parse operation succeeds, the resulting DateTime value has a time of midnight (00:00:00). If format defines a time with no date element and the parse operation succeeds, the resulting DateTime value has a date of DateTime.Now.Date.
If s does not represent a time in a particular time zone and the parse operation succeeds, the Kind property of the returned DateTime value is DateTimeKind..::.Unspecified. If s does represent the time in a particular time zone and format allows time zone information to be present (for example, if format is equal to the o, r, or u standard format specifiers, or if it contains the z, zz, or zzz custom format specifiers), the Kind property of the returned DateTime value is DateTimeKind..::.Local.
The format parameter is a string that contains either a single standard format specifier, or one or more custom format specifiers that define the required format of s. For details about valid formatting codes, see Standard Date and Time Format Strings or Custom Date and Time Format Strings.
Note: |
|---|
If format is a custom format pattern that does not include date or time separators (such as "yyyyMMdd HHmm"), use the invariant culture for the provider parameter and the widest form of each custom format specifier. For example, if you want to specify hours in the format pattern, specify the wider form, "HH", instead of the narrower form, "H". |
The particular date and time symbols and strings (such as names of the days of the week in a particular language) used in s are defined by the provider parameter, as is the precise format of s if format is a standard format specifier string. The provider parameter can be any of the following:
If provider is nullNothingnullptra null reference (Nothing in Visual Basic), the CultureInfo object that corresponds to the current culture is used.