title: Serialize Datetime without GMT in C#
body: <p>I have generated classes from xsd and want to serialize the <code>DateTime</code>. My class looks like</p>
  
  <pre><code>private System.DateTime timeGMT; 
  
   [System.Xml.Serialization.XmlElementAttribute(DataType="time")] 
   public System.DateTime TimeGMT { 
       get { 
           return this.timeGMT; 
       } 
       set { 
           this.timeGMT= value; 
       } 
   }
  </code></pre>
  
  <p>But when I assign any <code>DateTime</code> object It serializes in format as </p>
  
  <pre><code>&lt;TimeGMT&gt;12:00:00.0000000-04:00&lt;/TimeGMT&gt;
  </code></pre>
  
  <p>But I want it to be serialized as </p>
  
  <pre><code>&lt;TimeGMT&gt;12:00:00&lt;/TimeGMT&gt;
  </code></pre>
  
  <p>I had a look at this question :</p>
  
  <p><a href="https://stackoverflow.com/questions/101533/serializing-datetime-to-time-without-milliseconds-and-gmt">Serializing DateTime to time without milliseconds and gmt</a></p>
  
  <p>which is similar to my case. But my problem is I also want to validate the generated xml against xsd. So I cannot convert the return type to string. If I use String as return type then get an exception while generating XML: </p>
  
  <blockquote>
    <p>time is an invalid value for XMLElementAttribute.DataType property.The property may be specified for only primitive types.</p>
  </blockquote>
  
  <p>Is there any other way out there?</p>