.netframework3.5中TimeZoneInfo 类的使用
.net famework3.5中新增加了一个关于时区的静态类,可以使得我们方便的操作与时区相关的信息
下面的内容是摘自MSDN的信息,注意:这个类是Beta2中的类,至于Release后是否改变还不知道。由于电脑中没有安装英文正式版的MSDN,所以只能复制MSDN上的内容敬请谅解!
最下面的代码在英文正式版上调试的
时区是使用同一时间的地理区域。
TimeZoneInfo 扩展了 TimeZone 类,后者提供的是有限的功能。TimeZone 类只识别本地时区,但可以在协调世界时 (UTC) 和本地时间之间转换时间。TimeZoneInfo 对象可以表示任意时区,且 TimeZoneInfo 类的方法可用于将一个时区的时间转换为其他任意时区的相应时间。TimeZoneInfo 类的成员支持以下操作:
检索操作系统已定义的时区。
枚举系统上可用的时区。
在不同时区之间转换时间。
创建操作系统尚未定义的新时区。
序列化时区,供以后检索使用。
![]() |
---|
TimeZoneInfo 类的实例是不可变的。一旦实例化对象后,就无法修改其值。 |
您不能使用 new 关键字实例化 TimeZoneInfo 对象。相反,您必须调用下表所示的 TimeZoneInfo 类的静态成员之一。
静态成员名 |
说明 |
---|---|
CreateCustomTimeZone 方法 |
使用应用程序提供的数据创建自定义时区。 |
FindSystemTimeZoneById 方法 |
根据时区的标识符实例化在系统注册表中定义的时区。 |
FromSerializedString 方法 |
反序列化一个字符串值,以重新创建先前已序列化的 TimeZoneInfo 对象。 |
GetSystemTimeZones 方法 |
返回 TimeZoneInfo 对象的可枚举的 ReadOnlyCollection<(Of <(T>)>),它表示本地系统上可用的所有时区。 |
Local 属性 |
实例化表示本地时区的 TimeZoneInfo 对象。 |
Utc 属性 |
实例化表示 UTC 时区的 TimeZoneInfo 对象。 |
可以使用 CreateCustomTimeZone 方法创建在本地系统注册表中未定义的时区。然后可使用 ToSerializedString 属性将时区对象的信息保存为字符串,该字符串可以以应用程序可访问的某种格式存储。使用 FromSerializedString 方法可将序列化字符串转换回 TimeZoneInfo 对象。
下面是在英文正式版的代码
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
..{
Console.WriteLine(info[i].ToString());
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
以下是运行的结果:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
转载于:https://www.cnblogs.com/tengs2000/articles/1059561.html
.netframework3.5中TimeZoneInfo 类的使用相关推荐
- .netframework3.5 中TimeZoneInfo 类的使用
.net famework3.5中新增加了一个关于时区的静态类,可以使得我们方便的操作与时区相关的信息 下面的内容是摘自MSDN的信息,注意:这个类是Beta2中的类,至于Release后是否改变还不 ...
- java 枚举的继承_java中枚举类可以被继承吗?
java 枚举类 java中,使用关键字enum来定义枚举类,枚举类是一个特殊的类,大部分功能和普通类是一样的,区别为: ● 枚举类继承了java.lang.Enum类,而不是默认的Object类.而 ...
- c语言面向对象编程中的类_C ++中的面向对象编程
c语言面向对象编程中的类 Object oriented programming, OOP for short, aims to implement real world entities like ...
- python 类中定义类_Python中的动态类定义
python 类中定义类 Here's a neat Python trick you might just find useful one day. Let's look at how you ca ...
- Python中的类、模块和包究竟是什么?
Python培训教程:Python中的类.模块和包究竟是什么?在Python和其他编程语言中,都有类似或相同的概念,如对象.类.模块.包,名称都是一样的,只不过会有细微的一些区别,正是因为有这些存在, ...
- java中的类修饰符、成员变量修饰符、方法修饰符。
类修饰符: public(访问控制符),将一个类声明为公共类,他可以被任何对象访问,一个程序的主类必须是公共类. abstract,将一个类声明为抽象类,没有实现的方法,需要子类提供方法实现. fin ...
- java中properties作用,java中Properties类的使用
java中Properties类的使用 在java.util 包下面有一个类 Properties,该类主要用于读取以项目的配置文件(以.properties结尾的文件和xml文件). Propert ...
- Python3中的类和实例
1.类和实例 类是抽象的模板,实例是根据类创建出来的一个个具体的"对象".例如:动物是一大类,猫.狗.鱼等都是特定的对象,即实例.python3中使用class关键字来定义类,基本 ...
- php5中魔术方法函数有哪几个,php中的类魔术方法有哪些
php中的类魔术方法有:1.__sleep,返回一个包含对象中所有应被序列化的变量名称的数组:2.__tostring,返回一个类被当作字符串时要输出的内容:3.__construct,构造方法:4. ...
最新文章
- 深入探讨:视觉的目的是什么?
- 图形算法 - 模糊函数比较,Blur Function Compare
- ubuntu sublime字体设置
- SOCKET CLOSE_WAIT 搜集
- html5 字符相等,js里返回字符ok与字符ok比较不相等的问题
- 使用artTemplate模板将json转换为html页面
- 去掉超链接的颜色_Word中怎么快速批量删除去掉网站超链接技巧
- Linux系统不同主机之间的时间同步
- 定制简单的404和403页面
- 驱动精灵(Driver Genius Professional Edition 2007) v7.1.622 完美注册版(可升级)
- 用python实现阴阳师简单挂机脚本
- 润乾报表入门问题记录
- ThinkPHP5.0+七牛云SDK文件上传
- _variant_t与其他数据类型的转换
- 根据经度纬度获取距离(km/m)等工具类
- 算法利用:人机交互面临的道德漏洞
- x264中码率控制(二)x264_ratecontrol_start函数
- 我的微信小程序入门学习-地图定位
- MS系统老是跳服务器连接不上,无法连接到 DESKTOP-G 1I39VQ\MSSQLSERVER01 解决方法
- 2020.10.23--AI--小熊制作、太极制作、微信图标制作