Want to get rid of UTC offset in serialization of DateTime

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.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();
}





0
8/6/2004 8:48:05 AM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
883 Views

Similar Articles

[PageSpeed] 46

This example shows some of the possibilities.
http://www.winisp.net/cheeso/srcview.aspx?dir=xml-serialization&file=DateTime.cs

-D


"Bj�rnHolmberg" <bjRemovethiSorn.holmberg@suliteAndthiSlma.com> wrote in
message news:411345C6.4AFD1A22@suliteAndthiSlma.com...
> 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.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();
> }
>
>
>
>
>


0
dinoch1 (221)
8/11/2004 8:38:00 PM
Based on the ideas Dino sent me, I managed to find out a working solution to my
problem. I also realised that it's possible to keep xsd:dateTime in my schema and to
use it in a Web Service. Only drawback is that the wsdl can't be autogenerated.
Here's roughly what I came up with:

public class Approval {
 public string Manager;
 public int ProjectId;
 public string Location;
 public string ApprovedAt;

 [XmlIgnore]
 public DateTime LocalApprovedAt {
  get {
   return DateTime.Parse(ApprovedAt);
  }
  set {
   ApprovedAt = value.ToString("yyyy-MM-ddTHH:mm:ss");
  }
 }
}

public static void TestApproval() {
 Approval obj = new Approval();
 obj.Manager = "Smith";
 obj.ProjectId = 1234;
 obj.Location = "Pleasantville";
 obj.LocalApprovedAt = DateTime.Parse("2002-02-28 13:48:00");
 XmlSerializer serializer = new XmlSerializer(typeof(Approval));
 StreamWriter writer = new StreamWriter("obj.xml");
 serializer.Serialize(writer, obj);
 writer.Close();
}

/Bjorn

"Dino Chiesa [Microsoft]" wrote:

> This example shows some of the possibilities.
> http://www.winisp.net/cheeso/srcview.aspx?dir=xml-serialization&file=DateTime.cs
>
> -D
>
> "Bj�rnHolmberg" <bjRemovethiSorn.holmberg@suliteAndthiSlma.com> wrote in
> message news:411345C6.4AFD1A22@suliteAndthiSlma.com...
> > 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.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();
> > }
> >
> >
> >
> >
> >

0
8/15/2004 2:43:09 PM
Reply:

Similar Artilces:

want questions
Hello Everyone, I want some set of questions on Word-2007 to check competency level of the user. Please help. -- Ananta Gupta Ananta, please refer to my other 2 postings: just check out the WORD part. If my comments have helped please hit Yes. Thanks. "Ananta Gupta" wrote: > Hello Everyone, > > I want some set of questions on Word-2007 to check competency level of the > user. Please help. > > -- > Ananta Gupta "trip_to_tokyo" wrote: > Ananta, please refer to my other 2 postings: just check out the WOR...

Getting the ROW of a COUNTIF result?
Hi For a cyclingclub i want to make a simple statistic of the members and how many 1st places, 2nd. plcases and so on, they have had during the season. I have a excel sheet with all races in a season. In the 1st. coloum i have the name and in the second coloum the final position in the race. Name Plc. xxxx xxxxxxxxx 3 yyyy yyyyyyyyy 1 zzzz zzzzzzzzzzz 5 yyyy yyyyyyyyy 1 The statistic i want to make: Name Pcl-> 1 2 3 4 5 6 xxxx xxxxxxxxx 0 0 1 0 0 0 yyyy yyyyyyyyy 2 0 0 0...

I want more!
I need to extend a form that aleady has some 100 lines. For instance, one column has the date, but only until tomorroq. How do I create more lines based on the same formula? Thank you JB I usually select the last row in the range and copy it down a few rows. If you're using xl2003, you may want to look at Data|List. And if you're using xl2007, this feature has transformed into Tables. (Data tab on the ribbon|Data tools Group|What if Analysis|Data table) JB wrote: > > I need to extend a form that aleady has some 100 lines. For instance, one > column has the da...

How can I get a MFC DLL with NO own CWinApp/AfxGetApp() ?
I have a DLL which uses MFC and is compiled with /clr (because it contains classes which must be callable from C#). That works well when being used from a C# application by calling : if (!AfxWinInit(::GetModuleHandle("<dllname>"), NULL, ::GetCommandLine(), 0)) return false; AfxGetApp())->InitInstance(); so that the DLL has its own App-Object/State which is initialized by the above source code. But now I also want to use that DLL in a C++ MFC application which already has a CWinApp object; so I would like not to establish a new one for the DLL but use the one...

How do I get the sum total of all sheets in a workbook?
I have a 52 sheet workbook, all sheets have the same number of columns and data. What do I need to do to arrive at the sum total of all these sheets without printing them all out and adding them up manually? Thanks in advance for your assistance. Ortega, try something like this =SUM(Sheet1:Sheet52!A1) -- Paul B Always backup your data before trying something new Please post any response to the newsgroups so others can benefit from it Feedback on answers is always appreciated! Using Excel 2002 & 2003 "OrtegaGroup" <OrtegaGroup@discussions.microsoft.com> wrote in messa...

XML serialization problem #2
Hi all, I'm a .NET beginner and I've got a problem on a program where I try to do an XML serialization. I get the following error : "An unmanaged exception of type 'System.IO.FileNotFoundException' occured in mscorlib.dll Additonal information : the file or asssembly named n9gu4-bo.dll or one of its dependencies cannot be found" Here is the code : (I've uploaded the complete project at this url http://netorld.free.fr/Interface2.zip) public class Form1 : System.Windows.Forms.Form { .... .... public Form1() { InitializeComponent(); try { TextReader reade...

I don't want a page of the same label, I want one of each...
I can't find where to tell Pubisher that I want one of each label and not a page of each label. I'm using Publisher 2003 (Office 2003) I see a post that says to enter "<<Next Record>>" but Publisher doesn't see this as a field, just as text. This can't be that hard, but I can't figure it out... Any help would be appreciated. Kelvin I see that it prints correctly, but the print preview displayes it wrong.... I think I have it figured out... "Kelvin" <someone@domain.com> wrote in message news:OSpLwThUIHA.5508@TK2MSFTNGP04.phx....

Text want wrap in text box
I can't get the text to wrap in a text box, word wrap is set to true, I put some text boxes on a sheet today and the text will not wrap, I did this yesterday and it worked fine, I can copy the ones from yesterday and paste them on a new sheet and they work, any ideas? I have rebooted but this did not help. Using Excel 2000 (9.0.6926 SP3) Thanks Paul B If you're referring to a Control Toolbat text box make sure that the MultiLine property is True. -- Jim Rech Excel MVP "Paul B" <pbridgesnews@uga.edu> wrote in message news:%23ovLUkuLEHA.2456@TK2MSFTNGP12.phx.gbl......

Cannot access office out, getting POP3 Reporting Error 0X80042108
Hi there, i understand MS made some changes and now i am locked out from my MS Office Outlook. I get a POP3 Reporting Error # 0X80042108. The server does not recognize me. Is there any instructions on how to set or re-set this? Is there any REAL PERSON i can talk to for FREE Tech Support??? Thanks, Ray @ manauto@msn.com The changes were to how Outlook pulls Hotmail. Verify your settings against this: http://support.microsoft.com/kb/813514/en-us "Ray" <Ray@discussions.microsoft.com> wrote in message news:23A6252E-7B5F-454D-BB5A-5C9AB2B24DCD@microsoft.com... > Hi there...

Will illegal immigrants get deported?.........Of course not.....................
Our politicians just wanted to blow us some sunshine. Get the details from The Expert: http://www.ExpertHumor.com/ *** Free account sponsored by SecureIX.com *** *** Encrypt your Internet usage with a free VPN account from http://www.SecureIX.com *** ...

Want to Add more Sub description Field
How I can add more sub description field like 1,2,3,4,5 regards Saleem Suri Salaam Saleem, You have only limit up to 3 fields in RMS 1,2,3 sub-description also you can use the extended description and there is main description for the item. so Altogether you have upto 5 description limit and I think that is enough. Let me know if this won't fulfill your requirements else use the Item Notes for more description. Rate if like Regards Akber "Saleem Suri" wrote: > How I can add more sub description field like 1,2,3,4,5 > > regards > Saleem Suri Salam Akbar ...

I want to add a sound event when the cursor bumps left margin
I want to know (via an event sound) that my cursor movement has bumped the left edge of the spreadsheet. I am entering thousand of rows of data, and it would help if there was a event sound when I returned the cursor to the left edge. I have this feature in 123, and find it helpfull. Put this in the sheet module: Private Sub Worksheet_SelectionChange(ByVal Target As Range) Static ColOld As Integer If Target.Column = 1 And ColOld > 1 Then Beep ColOld = Target.Column End Sub -- Earl Kiosterud mvpearl omitthisword at verizon period net ------------------------------------------- "m...

Can I get Outlook 2007?
I have Office 2007, but Outlook Express. Am I able to get Outlook since I have Office 2007? If so, how can I get it installed? Depends which version of Office 2007, H&S doesnt feature Outlook Do you have any other Office version installed? "Marla" <Marla@discussions.microsoft.com> wrote in message news:A08412FA-D8F9-4D2C-8F93-175D2B4CF30F@microsoft.com... >I have Office 2007, but Outlook Express. Am I able to get Outlook since I > have Office 2007? If so, how can I get it installed? How can I tell? Where do I look? The menu items show Word, Pow...

Excel wants to create a page break in every cell!
After saving revisions in an Excel worksheet, I get a popup message that states "Margins do not fit page size". After clicking "ok" (because this is my only choice) a page break is automatically created in ever cell. At times(depending on the sizeof the work sheet) it can be over 100 pages with a page size 14% or smaller. Why does this happen, and how can I avoid it? I saw this suggestion in a different forum. Try closing excel. Clean up your windows temp folder Windows start button|Run type: %temp% and hit enter Clean all those files that you ca...

How do I get my email notifications to show?
I have all of the appropriate boxes checked under options, but when I minimze outlook, my notifications do not show up when an email is sent. Is there any help for that? "beezer" <beezer@discussions.microsoft.com> wrote in message news:CD01C95D-8679-43FA-9791-ACC1A3367A73@microsoft.com... >I have all of the appropriate boxes checked under options, but when I >minimze > outlook, my notifications do not show up when an email is sent. Is > there > any help for that? > Outlook doesn't present a notification with its tray icon on e-mail *sent*. I...

I get a #VALUE! msg.
Hello, I'm adding two columns, first- A7:A125 with the formula in A126 second- E7:E125 with the formula in E126 Then I divided the results for a percentage in a cell at the top E3. First question: Can I do this: =SUM(E7:E125)/(A7:A125) I mean obviously I can't because I get this error/if I can it will save me a bit of work... am I missing something? Second question: cell A126 has a total that I want to use in every calc as I copy it from E3 to F4 etc.... Regards, Kevin try =SUM(E7:E125)/sum(A7:A125) -- Don Guillett SalesAid Software donaldb@281.com "Kevin&qu...

WANTED
WTB: I BUY SOFTWARE - CHECK AROUND - YOU PROBABLY HAVE SOME OF THE BELOW TO SELL TO ME. SEE A LIST OF SOME OF THE SOFTWARE THAT I AM BUYING! I AM BUYING ALL OF THE BELOW. THE MORE QUANTITY THE BETTER! I am looking to buy large quantities of Windows 7 Professional Upgrade Dell DVDs with unactivated COAs included in a SEALED package I am looking to buy quantities of SYMANTEC NORTON ANTI VIRUS, NORTON INTERNET SECURITY AND 360 OEM AND RETAIL BOXES I will buy 2010, 2009, 2008, 2007 and 2006. If you have good quantities setting around and no longer need send me detai...

get/change and SY_User Company_Access_REL errors
Hello, I am testing a conversion from GP7.5 to GP8.0 and after the installation is completed and all data is transfered and the nesessary scripts run I am getting the following errors: when signing in with regular user: "A get/change first operation on table 'SY_Users_MSTR'failed accessing SQL data" when signing in with the 'sa' account: "SY_User_company_Access_REL'failed accessing SQL Data" Any thoughts on what might be causing this? Hi Are you transfering the data from 7.5 to 8 or have you done a v 8.00 upgrade from GP Utils? I dont recomm...

Check boxes
Hi---I am setting up a form with various check boxes. I want to set up a range of check boxes so if any of these boxes are checked, then one corresponding check box if also checked. On the flip side, if none in the range of boxes are checked, then the one corresponding box is also not checked. I hope this can be done with a formula or conditional formatting, instead of a macro....if it takes a macro, whoever resonds to this question, please explain in easy terms---I don't have a lot o fmacro experience. Thanks!!! A boolean checkbox reflects the TRUE / FALSE value of the cell it ...

My OnVScroll is not getting called!
I have a dialog class with an OnVScroll handler that is never getting called. My list box has the notify flag set, and I can't think of anything else to try. Any suggestions? -Eric What does gettting OnVScroll for your dialog have to do with a list box, and vice-versa? A list box does not notify its parent when it scrolls. OnVScroll would be sent to a window if the window itself has a scrollbar, either explicit or implicit, which has been scrolled. joe On Thu, 07 Apr 2005 00:39:19 -0500, Eric Adem <ecadem@earthlink.net> wrote: >I have a dialog class with an OnVScro...

Getting Shell Task ID from lost process
I am experiencing problems when using the Shell function in that periodically the returned task ID connection is lost. The external task/application launched via the Shell is still active, but the task ID becomes invalid. I seem to remember that somewhere in Access there used to be a way of scanning all active processes on the machine and interrogating their details in order to "grab" the appropriate process again. However, I cannot remember the technique or the add-in that does this. Can anyone remind me of the technique please? Thanks I am using Access 2003 on Win...

When repeating city want zipcode to populate
Making a data base of mailing addresses. Is there a formula to use to get a zipcode to populate in a cell when a city and state is entered in two other cells? Thanks. See help on VLOOKUP function. Or go here for excellent help and an example workbook. http://www.contextures.on.ca/xlFunctions02.html Gord Dibben MS Excel MVP On Wed, 21 Feb 2007 08:05:32 -0800, jrw - esq. <jrw - esq.@discussions.microsoft.com> wrote: >Making a data base of mailing addresses. Is there a formula to use to get a >zipcode to populate in a cell when a city and state is entered in two other >...

I want to know something about Visual Studio 2005
Hi, I want to know something about Visual Studio 2005 the size of it , and the System Requirements, who knows , please tell me. Thanks a lot. http://msdn.microsoft.com/vstudio/products/vspro/details/default.aspx -- Ajay Kalra [MVP - VC++] ajaykalra@yahoo.com "fcvcnet" <fcvcnet@163.com> wrote in message news:#xJvGnNPGHA.536@TK2MSFTNGP09.phx.gbl... > Hi, > I want to know something about Visual Studio 2005 > the size of it , and the System Requirements, who knows , please tell me. > Thanks a lot. > > Thank you so much! But I can not find the Visual Studi...

Want Windows Mail to open my live.com mail
What are the server settings to have my live.com mail open in my Windows Mail To access Hotmail accounts with Windows Mail, you have to use POP3. See href="http://mailcall.spaces.live.com/Blog/cns!CC9301187A51FE33!49799.entry Use port 587 for SMTP (outgoing) With the newer Windows Live Mail, it's much easier. Dave N. MS-MVP (Mail) Windows 7 Ultimate 64 http://download.live.com/wlmail "Sue Ann" wrote in message news:e$a0jezMLHA.1868@TK2MSFTNGP05.phx.gbl... What are the server settings to have my live.com mail open in my Windows Mail ...

How do I get Visio 2003 to update shapes from Visio 2000?
I have upgraded to isio 2003 and when opening drawings created in Visio 2000, I get a message that says "The MS Visio building plan shapes in the drawing must be updated to function in the current version of Visio." When I click 'Yes", all the shapes are deleted. When I click "No", it opens with the shapes intact. Any way to point Visio 2003 to the Visio 2000 shapes? ...