.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. ...
最新文章
- Master RenderMan Procedural Primitive DSO
- java汽车租赁系统_汽车租赁公司全网低价
- HTML5 - Canvas动画样例(谷歌弹跳球)
- 小技巧来助阵 玩转Google Chrome(谷歌浏览器)
- 腾讯再诉今日头条系 要求删除用户游戏视频
- python数据分析与excel_读Python数据分析基础之Excel读写与处理
- LuaTinker向Linux移植成功
- kafka安装使用说明
- vue ,solt 插值组件新内容
- plsql破解的办法
- Win10黑屏的时候显示时钟怎么设置
- gtp传输java_一种GTP数据包传输方法、相关装置及存储介质与流程
- Linux系统安装Node.js步骤
- 一个项目经理的经验总结_小七_新浪博客
- Android游戏开发是视频教程
- 如何完成上传图片到腾讯云
- USB键盘在DOS下无法用,在BIOS和WIN中正常,奇怪情况,原来是PS2接口有问题
- 【测试基础】之03 CSS入门基础
- QoS服务质量六路由器拥塞管理
- 51单片机串口通信模板_51单片机串口通信
热门文章
- 手把手的 git 降伏指南——阿龙咸鱼经
- 计算机专业推山西新华电脑学校,青春启航,乘风破浪|山西新华电脑学校2021届毕业典礼完美落幕...
- app不能备份数据,更改allowBackup为true,并重新打包apk
- MATLAB-基于长短期记忆网络(LSTM)的SP500的股票价格预测 股价预测 matlab实战 数据分析 数据可视化 时序数据预测 变种RNN 股票预测
- ITU-R BT.601 Y'CbCr
- 计算机闪存大小,电脑内存大小有什么区别
- 【论文翻译】ADVIO: An Authentic Dataset for Visual-Inertial Odometry
- 计算机图像学基础课程设计,计算机图形学课程设计
- python爬虫(1)-百度新闻首页抓取
- txt电子书如何用Windows电脑阅读?