Want to get rid of UTC offset in serialization of DateTime

B

BjörnHolmberg

Hi everyone!

In the following code we get a UTC offset in xml. Since I want my WAP users in
UTC+02:00 to see data on a server in some US time zone, a lot of confusion will
be created from this behavior. Either I use .NET logic on the server and get
server local time or I create xhtml pages directly from serialized objects.
Eitherway I'll have to write my own logic to take care of utc offset. Is it
possible to override XmlSerializer so what my local desktop user send to the
webservice is saved on the server without utc offset? That way, the time that is
local to my users will be saved on the server. I guess it's kind of hard to
tweak ASP.NET WebService infrastructure into this. On the other hand it feels
like bad manners to change my xsd:dateTime values to xsd:string because of what
i discover about .NET. /Regards Bjorn

public class SomeDates {
public DateTime Summer;
public DateTime Winter;
}

public static void TestSomeDates() {
SomeDates obj = new SomeDates();
obj.Winter = DateTime.UtcNow.Parse("2003-12-22 12:32:45");
obj.Summer = DateTime.Parse("2004-08-05 18:45:21");
XmlSerializer serializer = new XmlSerializer(typeof(SomeDates));
StreamWriter writer = new StreamWriter("obj.xml");
serializer.Serialize(writer, obj);
writer.Close();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top