Date Without Time When Serializing

I’m serializing a class in .NET and have a DateTime field.   It’s getting serialized as:

2009-11-01T00:00:00

When what I really want is something without the time like this:

2009-11-01

Brad Abrams has a great post that has how to do this (plus a lot more).   Simply add this attribute to the property:

[XmlElementAttribute(DataType=”date”)]

This is probably basic to some, but was helpful to me.

This entry was posted in Code/Development, Technology. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *