System.Xml.XmlConvert.ToDateTimeOffset Method

Converts the supplied string to a DateTimeOffset equivalent.

Syntax

public static DateTimeOffset ToDateTimeOffset (string s, string[] formats)

Parameters

s
The string to convert.
formats
An array of formats from which s can be converted. Each format in formats can be any subset of the W3C Recommendation for the XML dateTime type. (For more information see http://www.w3.org/TR/xmlschema-2/#dateTime.) The string s is validated against one of these formats.

Returns

The DateTimeOffset equivalent of the supplied string.

Remarks

If the offset specified within the input string will cause an overflow in the deserialized representation of the DateTimeOffset, a FormatException is thrown.

When more than seven digits are specified for fractional seconds, the value is rounded. For example, 00000004 becomes 0000000 and 00000005 becomes 0000001.

Requirements

Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0