.net famework3.5中新增加了一个关于时区的静态类,可以使得我们方便的操作与时区相关的信息

下面的内容是摘自MSDN的信息,注意:这个类是Beta2中的类,至于Release后是否改变还不知道。由于电脑中没有安装英文正式版的MSDN,所以只能复制MSDN上的内容敬请谅解!

最下面的代码在英文正式版上调试的

时区是使用同一时间的地理区域。

TimeZoneInfo 扩展了 TimeZoneInfo 类的成员支持以下操作:

  • 检索操作系统已定义的时区。

  • 枚举系统上可用的时区。

  • 在不同时区之间转换时间。

  • 创建操作系统尚未定义的新时区。

  • 序列化时区,供以后检索使用。

.netframework3.5中TimeZoneInfo 类的使用注意:

TimeZoneInfo 类的实例是不可变的。一旦实例化对象后,就无法修改其值。

您不能使用 new 关键字实例化 TimeZoneInfo 对象。相反,您必须调用下表所示的 TimeZoneInfo 类的静态成员之一。

静态成员名

说明

CreateCustomTimeZone 方法

使用应用程序提供的数据创建自定义时区。

FindSystemTimeZoneById 方法

根据时区的标识符实例化在系统注册表中定义的时区。

FromSerializedString 方法

反序列化一个字符串值,以重新创建先前已序列化的 TimeZoneInfo 对象。

GetSystemTimeZones 方法

返回 TimeZoneInfo 对象的可枚举的 ),它表示本地系统上可用的所有时区。

Local 属性

实例化表示本地时区的 TimeZoneInfo 对象。

Utc 属性

实例化表示 UTC 时区的 TimeZoneInfo 对象。

可以使用 TimeZoneInfo 对象。

 

下面是在英文正式版的代码

 

.netframework3.5中TimeZoneInfo 类的使用  //本地时区信息
.netframework3.5中TimeZoneInfo 类的使用
            TimeZoneInfo t=TimeZoneInfo.Local;
.netframework3.5中TimeZoneInfo 类的使用            Console.WriteLine(t.DaylightName
+" ");
.netframework3.5中TimeZoneInfo 类的使用            Console.WriteLine(t.DisplayName 
+ " ");
.netframework3.5中TimeZoneInfo 类的使用            Console.WriteLine(t.Id 
+ " ");
.netframework3.5中TimeZoneInfo 类的使用            Console.WriteLine(t.StandardName 
+ " ");
.netframework3.5中TimeZoneInfo 类的使用            Console.WriteLine(t.SupportsDaylightSavingTime.ToString() 
+ " ");
.netframework3.5中TimeZoneInfo 类的使用            Console.WriteLine(t.ToSerializedString() 
+ " ");
.netframework3.5中TimeZoneInfo 类的使用            Console.ReadLine();
.netframework3.5中TimeZoneInfo 类的使用
.netframework3.5中TimeZoneInfo 类的使用            System.Collections.ObjectModel.ReadOnlyCollection
<TimeZoneInfo> info = TimeZoneInfo.GetSystemTimeZones();
.netframework3.5中TimeZoneInfo 类的使用            Console.WriteLine(
"以下是所有的时区列表"+" ");
.netframework3.5中TimeZoneInfo 类的使用            
for (int i=0; i < info.Count; i++)
         
{
                Console.WriteLine(info[i].ToString());
            }

.netframework3.5中TimeZoneInfo 类的使用            Console.ReadLine();

以下是运行的结果:

 

.netframework3.5中TimeZoneInfo 类的使用中国夏季时间
.netframework3.5中TimeZoneInfo 类的使用
.netframework3.5中TimeZoneInfo 类的使用(GMT+08:00) 北京,重庆,香港特别行政区,乌鲁木齐
.netframework3.5中TimeZoneInfo 类的使用
.netframework3.5中TimeZoneInfo 类的使用China Standard Time
.netframework3.5中TimeZoneInfo 类的使用
.netframework3.5中TimeZoneInfo 类的使用中国标准时间
.netframework3.5中TimeZoneInfo 类的使用
.netframework3.5中TimeZoneInfo 类的使用False
.netframework3.5中TimeZoneInfo 类的使用
.netframework3.5中TimeZoneInfo 类的使用China Standard Time;480;(GMT+08:00) 北京,重庆,香港特别行政区,乌鲁木齐;中国标
.netframework3.5中TimeZoneInfo 类的使用准时间;中国夏季时间;;
.netframework3.5中TimeZoneInfo 类的使用
.netframework3.5中TimeZoneInfo 类的使用
.netframework3.5中TimeZoneInfo 类的使用以下是所有的时区列表
.netframework3.5中TimeZoneInfo 类的使用
.netframework3.5中TimeZoneInfo 类的使用(GMT) 卡萨布兰卡,蒙罗维亚,雷克雅未克
.netframework3.5中TimeZoneInfo 类的使用(GMT) 格林威治标准时间: 都柏林, 爱丁堡, 伦敦, 里斯本
.netframework3.5中TimeZoneInfo 类的使用(GMT+01:00) 中非西部
.netframework3.5中TimeZoneInfo 类的使用(GMT+01:00) 布鲁塞尔,哥本哈根,马德里,巴黎
.netframework3.5中TimeZoneInfo 类的使用(GMT+01:00) 萨拉热窝,斯科普里,华沙,萨格勒布
.netframework3.5中TimeZoneInfo 类的使用(GMT+01:00) 贝尔格莱德,布拉迪斯拉发,布达佩斯,卢布尔雅那,布拉格
.netframework3.5中TimeZoneInfo 类的使用(GMT+01:00) 阿姆斯特丹,柏林,伯尔尼,罗马,斯德哥尔摩,维也纳
.netframework3.5中TimeZoneInfo 类的使用(GMT+02:00) 哈拉雷,比勒陀利亚
.netframework3.5中TimeZoneInfo 类的使用(GMT+02:00) 安曼
.netframework3.5中TimeZoneInfo 类的使用(GMT+02:00) 开罗
.netframework3.5中TimeZoneInfo 类的使用(GMT+02:00) 明斯克
.netframework3.5中TimeZoneInfo 类的使用(GMT+02:00) 温得和克
.netframework3.5中TimeZoneInfo 类的使用(GMT+02:00) 耶路撒冷
.netframework3.5中TimeZoneInfo 类的使用(GMT+02:00) 贝鲁特
.netframework3.5中TimeZoneInfo 类的使用(GMT+02:00) 赫尔辛基,基辅,里加,索非亚,塔林,维尔纽斯
.netframework3.5中TimeZoneInfo 类的使用(GMT+02:00) 雅典,布加勒斯特,伊斯坦布尔
.netframework3.5中TimeZoneInfo 类的使用(GMT+03:00) 内罗毕
.netframework3.5中TimeZoneInfo 类的使用(GMT+03:00) 巴格达
.netframework3.5中TimeZoneInfo 类的使用(GMT+03:00) 科威特,利雅得
.netframework3.5中TimeZoneInfo 类的使用(GMT+03:00) 第比利斯
.netframework3.5中TimeZoneInfo 类的使用(GMT+03:00) 莫斯科,圣彼得堡, 伏尔加格勒
.netframework3.5中TimeZoneInfo 类的使用(GMT+03:30) 德黑兰
.netframework3.5中TimeZoneInfo 类的使用(GMT+04:00) 埃里温
.netframework3.5中TimeZoneInfo 类的使用(GMT+04:00) 巴库
.netframework3.5中TimeZoneInfo 类的使用(GMT+04:00) 阿布扎比,马斯喀特
.netframework3.5中TimeZoneInfo 类的使用(GMT+04:00) 高加索标准时间
.netframework3.5中TimeZoneInfo 类的使用(GMT+04:30) 喀布尔
.netframework3.5中TimeZoneInfo 类的使用(GMT+05:00) 伊斯兰堡,卡拉奇,塔什干
.netframework3.5中TimeZoneInfo 类的使用(GMT+05:00) 叶卡捷琳堡
.netframework3.5中TimeZoneInfo 类的使用(GMT+05:30) 斯里哈亚华登尼普拉
.netframework3.5中TimeZoneInfo 类的使用(GMT+05:30) 马德拉斯,加尔各答,孟买,新德里
.netframework3.5中TimeZoneInfo 类的使用(GMT+05:45) 加德满都
.netframework3.5中TimeZoneInfo 类的使用(GMT+06:00) 阿拉木图,新西伯利亚
.netframework3.5中TimeZoneInfo 类的使用(GMT+06:00) 阿斯塔纳,达卡
.netframework3.5中TimeZoneInfo 类的使用(GMT+06:30) 仰光
.netframework3.5中TimeZoneInfo 类的使用(GMT+07:00) 克拉斯诺亚尔斯克
.netframework3.5中TimeZoneInfo 类的使用(GMT+07:00) 曼谷,河内,雅加达
.netframework3.5中TimeZoneInfo 类的使用(GMT+08:00) 伊尔库茨克,乌兰巴图
.netframework3.5中TimeZoneInfo 类的使用(GMT+08:00) 北京,重庆,香港特别行政区,乌鲁木齐
.netframework3.5中TimeZoneInfo 类的使用(GMT+08:00) 台北
.netframework3.5中TimeZoneInfo 类的使用(GMT+08:00) 吉隆坡,新加坡
.netframework3.5中TimeZoneInfo 类的使用(GMT+08:00) 珀斯
.netframework3.5中TimeZoneInfo 类的使用(GMT+09:00) 大坂,札幌,东京
.netframework3.5中TimeZoneInfo 类的使用(GMT+09:00) 汉城
.netframework3.5中TimeZoneInfo 类的使用(GMT+09:00) 雅库茨克
.netframework3.5中TimeZoneInfo 类的使用(GMT+09:30) 达尔文
.netframework3.5中TimeZoneInfo 类的使用(GMT+09:30) 阿德莱德
.netframework3.5中TimeZoneInfo 类的使用(GMT+10:00) 关岛,莫尔兹比港
.netframework3.5中TimeZoneInfo 类的使用(GMT+10:00) 堪培拉,墨尔本,悉尼
.netframework3.5中TimeZoneInfo 类的使用(GMT+10:00) 布里斯班
.netframework3.5中TimeZoneInfo 类的使用(GMT+10:00) 符拉迪沃斯托克
.netframework3.5中TimeZoneInfo 类的使用(GMT+10:00) 霍巴特
.netframework3.5中TimeZoneInfo 类的使用(GMT+11:00) 马加丹,索罗门群岛,新喀里多尼亚
.netframework3.5中TimeZoneInfo 类的使用(GMT+12:00) 奥克兰,惠灵顿
.netframework3.5中TimeZoneInfo 类的使用(GMT+12:00) 斐济,堪察加半岛,马绍尔群岛
.netframework3.5中TimeZoneInfo 类的使用(GMT+13:00) 努库阿洛法
.netframework3.5中TimeZoneInfo 类的使用(GMT-01:00) 亚速尔群岛
.netframework3.5中TimeZoneInfo 类的使用(GMT-01:00) 佛得角群岛
.netframework3.5中TimeZoneInfo 类的使用(GMT-02:00) 中大西洋
.netframework3.5中TimeZoneInfo 类的使用(GMT-03:00) 巴西利亚
.netframework3.5中TimeZoneInfo 类的使用(GMT-03:00) 布宜诺斯艾利斯,乔治敦
.netframework3.5中TimeZoneInfo 类的使用(GMT-03:00) 格陵兰
.netframework3.5中TimeZoneInfo 类的使用(GMT-03:00) 蒙得维的亚
.netframework3.5中TimeZoneInfo 类的使用(GMT-03:30) 纽芬兰
.netframework3.5中TimeZoneInfo 类的使用(GMT-04:00) 圣地亚哥
.netframework3.5中TimeZoneInfo 类的使用(GMT-04:00) 大西洋时间(加拿大)
.netframework3.5中TimeZoneInfo 类的使用(GMT-04:00) 拉巴斯
.netframework3.5中TimeZoneInfo 类的使用(GMT-04:00) 马瑙斯
.netframework3.5中TimeZoneInfo 类的使用(GMT-04:30) 加拉加斯
.netframework3.5中TimeZoneInfo 类的使用(GMT-05:00) 东部时间(美国和加拿大)
.netframework3.5中TimeZoneInfo 类的使用(GMT-05:00) 印地安那州(东部)
.netframework3.5中TimeZoneInfo 类的使用(GMT-05:00) 波哥大,利马,里奥布朗库
.netframework3.5中TimeZoneInfo 类的使用(GMT-06:00) 中美洲
.netframework3.5中TimeZoneInfo 类的使用(GMT-06:00) 中部时间(美国和加拿大)
.netframework3.5中TimeZoneInfo 类的使用(GMT-06:00) 瓜达拉哈拉,墨西哥城,蒙特雷(新)
.netframework3.5中TimeZoneInfo 类的使用(GMT-06:00) 瓜达拉哈拉,墨西哥城,蒙特雷(旧)
.netframework3.5中TimeZoneInfo 类的使用(GMT-06:00) 萨斯喀彻温
.netframework3.5中TimeZoneInfo 类的使用(GMT-07:00) 亚利桑那
.netframework3.5中TimeZoneInfo 类的使用(GMT-07:00) 奇瓦瓦,拉巴斯,马扎特兰(新)
.netframework3.5中TimeZoneInfo 类的使用(GMT-07:00) 奇瓦瓦,拉巴斯,马萨特兰(旧)
.netframework3.5中TimeZoneInfo 类的使用(GMT-07:00) 山地时间(美国和加拿大)
.netframework3.5中TimeZoneInfo 类的使用(GMT-08:00) 太平洋时间(美国和加拿大)
.netframework3.5中TimeZoneInfo 类的使用(GMT-08:00) 蒂华纳,下加利福尼亚州
.netframework3.5中TimeZoneInfo 类的使用(GMT-09:00) 阿拉斯加
.netframework3.5中TimeZoneInfo 类的使用(GMT-10:00) 夏威夷
.netframework3.5中TimeZoneInfo 类的使用(GMT-11:00) 中途岛,萨摩亚群岛
.netframework3.5中TimeZoneInfo 类的使用(GMT-12:00)日界线西
.netframework3.5中TimeZoneInfo 类的使用

 

 

相关文章:

  • 2021-08-09
  • 2021-08-02
  • 2021-05-20
  • 2022-12-23
  • 2022-12-23
  • 2021-08-25
  • 2021-11-29
  • 2021-12-28
猜你喜欢
  • 2022-02-15
  • 2022-12-23
  • 2022-12-23
  • 2021-05-25
  • 2021-05-19
  • 2021-07-31
  • 2022-01-09
相关资源
相似解决方案