c#中时间类的使用

c#中DateTime类的起始时间是0001年。

而java中的起始是1970年,c#中如何生成一个java的起始时间等效的对象呢?

如下代码表示了Ticks的概念和dateTime的解析:

DateTime dt = DateTime.Parse("01/01/1970 00:00:0");

DateTime dt3 = new DateTime(dt.Ticks);
          DateTime dt4 = dt3.AddTicks(100000000); //ticks的单位毫微秒
          //1微秒=10000毫微秒
          DateTime dt2 = dt.AddMilliseconds(10000);//微秒
          Console.WriteLine(dt2);
          Console.WriteLine(dt4);

posted @ 2010-09-23 14:31  xujie  Views(652)  Comments(0)    收藏  举报