serialize object date/time
<p>I have one problem. I have to serialize an object and that sam object is converted to XML, but it's a datetime object.</p>

<p>Ok, i have string variable which is filled with data from some sql query, like this</p>

<p>//DateDeliveryRequest</p>

<pre><code> if (rw_mat["dat_pot"].ToString().Length &lt;= 0)
     {
           date_req = "";
     }
     else
     {
           date_req = rw_mat["dat_pot"].ToString();
     }
</code></pre>

<p>Now, date_req is being passet to object like this:</p>

<pre><code>var dtfi = new DateTimeFormatInfo { ShortDatePattern = "dd-MM-yyyy", DateSeparator = "-" };
Agr3PL.DataArea.Header.DateDeliveryRequest = Convert.ToDateTime(date_req, dtfi);
</code></pre>

<p>And at the end this object with among other is being passed to serialize function:</p>

<pre><code> private string SerializeAnObject(object obj)
            {

                System.Xml.XmlDocument doc = new XmlDocument();

                System.Xml.Serialization.XmlSerializer serializer = new        System.Xml.Serialization.XmlSerializer(obj.GetType());

                System.IO.MemoryStream stream = new System.IO.MemoryStream();

                try
                {

                    serializer.Serialize(stream, obj);

                    stream.Position = 0;

                    doc.Load(stream);

                    return doc.InnerXml;

                }

                catch (Exception ex)
                {
                    WriteErrors.WriteToLogFile("WS.SAVE_DOK_SERIJALIZACIJA", ex.ToString());

                    throw ex;

                }
</code></pre>

<p>So i want to get datetime variable to xml but I don't, the xml has to look something like this(It is just a segment)</p>

<pre><code>- &lt;Header&gt;
  &lt;MessageType&gt;COR&lt;/MessageType&gt; 
  &lt;UniqueHeaderNumber /&gt; 
  &lt;UniqueHeaderNumberFromWMS /&gt; 
  &lt;CompanyCode /&gt; 
  &lt;OrderNumber /&gt; 
  &lt;InvoiceNumber /&gt; 
  &lt;MovementNumber /&gt; 
  &lt;ReceiptNumber /&gt; 
  &lt;DebitNoteNumber /&gt; 
  &lt;PickNoteNumber /&gt; 
  &lt;LoadNumber /&gt; 
  &lt;DropSequence /&gt; 
  &lt;BulkPickNoteNumber /&gt; 
  &lt;NumberOfPallets /&gt;
  &lt;DateDeliveryRequest /&gt;
</code></pre>

<p>But the problem is that the xml is not showing the node >DateDeliveryRequest it's not there
I don't get error just there is no node >DateDeliveryRequest???</p>

<p>I don't know is it the problem in serializer function or on something else, maybe in formating date or something else?</p>
