EDN Admin
Well-known member
Serializing a DateTime using the code below produces some unexpected results. If I specify type as xs:dateTime the result is as expected, i.e. "2009-12-24T08:30:00Z". Now, if I change the type to xs:time, I assumed the result would be "08:30:00Z".... but
it is not. I get "08:30:00.0000000+02:00". Dont look like utc to me. What am I missing here?
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; class Program
{
<span style="color:Blue; static <span style="color:Blue; void Main(<span style="color:Blue; string[] args)
{
UtcDate ud = <span style="color:Blue; new UtcDate { EventTime = <span style="color:Blue; new DateTime(2009,12,24,8,30,0, DateTimeKind.Utc) };
XmlSerializer xs = <span style="color:Blue; new XmlSerializer(<span style="color:Blue; typeof(UtcDate));
xs.Serialize(Console.Out, ud);
}
}
<span style="color:Blue; public <span style="color:Blue; class UtcDate
{
<span style="color:Green; //[System.Xml.Serialization.XmlTextAttribute(DataType = "dateTime")] // <- OK, serialied as UTC
[System.Xml.Serialization.XmlTextAttribute(DataType = <span style="color:#A31515; "time")]
<span style="color:Blue; public DateTime EventTime { <span style="color:Blue; get; <span style="color:Blue; set; }
}
[/code]
View the full article
it is not. I get "08:30:00.0000000+02:00". Dont look like utc to me. What am I missing here?
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; class Program
{
<span style="color:Blue; static <span style="color:Blue; void Main(<span style="color:Blue; string[] args)
{
UtcDate ud = <span style="color:Blue; new UtcDate { EventTime = <span style="color:Blue; new DateTime(2009,12,24,8,30,0, DateTimeKind.Utc) };
XmlSerializer xs = <span style="color:Blue; new XmlSerializer(<span style="color:Blue; typeof(UtcDate));
xs.Serialize(Console.Out, ud);
}
}
<span style="color:Blue; public <span style="color:Blue; class UtcDate
{
<span style="color:Green; //[System.Xml.Serialization.XmlTextAttribute(DataType = "dateTime")] // <- OK, serialied as UTC
[System.Xml.Serialization.XmlTextAttribute(DataType = <span style="color:#A31515; "time")]
<span style="color:Blue; public DateTime EventTime { <span style="color:Blue; get; <span style="color:Blue; set; }
}
[/code]
View the full article