Bug 27901 - XmlConvert.ToString(DateTimeOffset) returns wrong value
Summary: XmlConvert.ToString(DateTimeOffset) returns wrong value
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.16.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Ankit Jain
Depends on:
Reported: 2015-03-11 13:52 UTC by nader
Modified: 2015-03-16 09:32 UTC (History)
1 user (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description nader 2015-03-11 13:52:55 UTC
It appears that XmlConvert.ToString(DateTimeOffset) returns inconsistent results compared to .Net. 

To reproduce this issue run the following code snippet

System.DateTimeOffset v1 = (System.DateTimeOffset)(System.Array.CreateInstance(typeof(System.DateTimeOffset), 1)).GetValue(0);
System.String v2 = System.Xml.XmlConvert.ToString((System.DateTimeOffset)v1);

Expected Output (Windows Phone8.1): "0001-01-01T00:00:00Z"
Xamarin Android Output: "0001-01-01T00:00:00+00:00"

This code snippet was placed in a PCL project and was run on an android 4.4.2 emulator and a Windows Phone 8.1 emulator

Additional Build Environment info:
Xamarin.Android Version: 4.16.0 (Business Edition)
Java SDK: C:\Program Files (x86)\Java\jdk1.6.0_39
Comment 1 Ankit Jain 2015-03-16 07:21:12 UTC
Fixed on mono master, as a result of the move to System.XML from referencesource.
Comment 2 Ankit Jain 2015-03-16 09:32:06 UTC
Note: this should be fixed as of ~ 50db47379083f823d0942870468df1fcda971f97 . This was tested with f482b9bd9b890cd99c3b93872a337b2b65f8f12b though.