0

I have a class with Getter and Setter:

public class MyClassEntity
{
    public DateTime MyDate { get; set; }    
}

public MyClassEntity MyData { get; set; } 

That class is serialized from xml generated by Stored Procedure. This is an XML portion that is serialized to MyData class

  <MyData>
    <MyDate>2017-03-29</MyDate>
  </MyData>

I'm looking for the solution to return MyDate.ToLongDateString() to my model.

I tried a couple of things but that did not help much.

I was trying to declare a string and assign a value.ToLongDateString() I could not convert value to what I need.

How can I do that?

Rand Random
  • 7,300
  • 10
  • 40
  • 88
gene
  • 2,098
  • 7
  • 40
  • 98
  • what are the ouput that you've seen so far ? – Kevin Avignon Dec 11 '17 at 15:00
  • I don't understand. A `DateTime` has no format. I don't understand why calling `MyDate.ToString("your format here");` doesn't suffice? – Equalsk Dec 11 '17 at 15:01
  • What I need to do is return value converted to LongDateString – gene Dec 11 '17 at 15:02
  • 3
    Possible duplicate of [Force XmlSerializer to serialize DateTime as 'YYYY-MM-DD hh:mm:ss'](https://stackoverflow.com/questions/3534525/force-xmlserializer-to-serialize-datetime-as-yyyy-mm-dd-hhmmss) – James Thorpe Dec 11 '17 at 15:13

0 Answers0