|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DataColumn.DateTimeMode property - How to use it?Hello,
Not so long ago I accidentally noticed this new DataColumn.DateTimeMode property. I thought myself: what a cool concept! Perhaps data bound controls can use this setting to automatically perform conversion to/from UTC time when binding/unbinding. However, so far I found no control using this property that way. I am wondering what the purpose for the property is. How should it be used? MSDN documentation is rather enigmatic in that respect. Thank you, Tomasz Hi Tomasz,
First of all, I'd like to confirm my understanding of your issue. According to your description, I understand that you want to know what the purpose for the property "DateTimeMode" is and how to use it. If I misunderstand anything here, please don't hesitate to correct me. As you know, "DataColumn.DateTimeMode" is used to conversion to/from UTC time. For example: System.Data.DataTable dt = new DataTable(); System.Data.DataColumn dc1 = new DataColumn("time1",typeof(System.DateTime)); dt.Columns.Add(dc1); dc1.DateTimeMode = System.Data.DataSetDateTime.Utc; dr1[0] = new System.DateTime(2005,12,12,00,00,59,DateTimeKind.Local); //dr1[0] = new System.DateTime(2005,12,12,00,00,59,DateTimeKind.Utc); dt.Rows.Add(dr1); Response.Write(dt.Rows[0][0]); You can find the value outputed will be convered between UTC and Local. So here comes the DateTimeMode in .NET 2.0. We can set each individual column to the mode we want. Under my research on internet, I found there is an good article descripts how it should be used and what we should pay attention to. http://bethmassi.blogspot.com/2006/01/serializing-data-across-time-zones-in. html If there is anything unclear, please feel free to contact me. I'm glad to assist you. Sincerely, WenYuan
Other interesting topics
|
|||||||||||||||||||||||