I have a XSD schema for some RESTful service. When used in conjunction with xsd.exe
tool to generate C# code, XSD's xs:date
generates the following code:
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, DataType="date")]
public System.DateTime time {
get {
return this.timeField;
}
set {
this.timeField = value;
}
}
When deserializing XML to objects using XmlSerializer
all seems to be well. The problem I am facing is that the service expects dates to be formatted as YYYY-MM-DD hh:mm:ss
and the XSD generated code seems to produce only YYYY-MM-DD
.
If I modify XSD manually to xs:dateTime
type, the generated C# code produces: 2010-08-20T20:07:03.915039Z
.
Basically, how do I force serialization to produce YYYY-MM-DD hh:mm:ss
? Is there something to do to XSD or is there something I can do to alter generated C# code?