Converts the specified string representation of a date and time to its DateTimeOffset equivalent using the specified culture-specific format information.
An object that is equivalent to the date and time that is contained in input, as specified by formatProvider.
This method parses a string with three elements that can appear in any order and are delimited by white space. These three elements are shown in the following table.
<Date> |
"2/10/2007" |
<Time> |
"1:02:03 PM" |
<Offset> |
"-7:30:15" |
Although each of these elements is optional, <Offset> cannot appear by itself. It must be provided together with either <Date> or <Time>. If <Date> is missing, its default value is the current day. If <Date> is present but its year component consists of only two digits, it is converted to a year in the provider parameter's current calendar based on the value of the System.Globalization.Calendar.TwoDigitYearMax property. If <Time> is missing, its default value is 12:00:00 AM. If <Offset> is missing, its default value is the offset of the local time zone. <Offset> can represent either a negative or a positive offset from Coordinated Universal Time (UTC). In either case, <Offset> must include a sign symbol.
The format of these three elements is defined by the formatProvider parameter, which can be either of the following:
A System.Globalization.CultureInfo object that represents the culture whose formatting is used in the input parameter. The System.Globalization.DateTimeFormatInfo object returned by the System.Globalization.CultureInfo.DateTimeFormat property defines the formatting used in input.
A System.Globalization.DateTimeFormatInfo object that defines the format of date and time data.
If formatprovider is null, the System.Globalization.CultureInfo object that corresponds to the current culture is used.
The positive or negative sign used in <Offset> must be either + or -. It is not defined by the System.Globalization.NumberFormatInfo.PositiveSign or System.Globalization.NumberFormatInfo.NegativeSign properties of the System.Globalization.NumberFormatInfo object of the formatProvider parameter.