您现在的位置是:首页
>
属于日期时间型的数据类型是 使用.NET Framework中新的日期时间类型[4]
使用.NET Framework中新的日期时间类型[4] 如果在转换时指定的时间是U ecified 转换后产生的DateTimeOff et的值的偏移量将会为本地时区 如下代码所示 tatic
使用.NET Framework中新的日期时间类型[4]
如果在转换时指定的时间是Unspecified 转换后产生的DateTimeOffset的值的偏移量将会为本地时区 如下代码所示
![属于日期时间型的数据类型是 使用.NET Framework中新的日期时间类型[4]](http://img.zhputi.com/uploads/44e4/44e4cfc4c2bfd63187d1c613a22a092e23474.jpg)
static void Main(string[] args){ DateTime dateA = new DateTime( ); DateTime dateB = DateTime SpecifyKind(dateA DateTimeKind Unspecified); DateTimeOffset dateC = dateB; Console WriteLine(dateB); Console WriteLine(dateC);}
输出结果如下图所示 可以看到它产生的输出是本地时区
这一点其实从DateTimeOffset的一个参数为DateTime的构造函数中就能够看出来 它只判断DateTime是否为UTC 否则就取当前本地时区的偏移量
public DateTimeOffset(DateTime dateTime) { TimeSpan offset; if (dateTime Kind != DateTimeKind Utc) { // Local 和 Unspecified 都转换为Local offset = TimeZone CurrentTimeZone GetUtcOffset(dateTime); } else { offset = new TimeSpan( ); } m_offsetMinutes = ValidateOffset(offset); m_dateTime = ValidateDate(dateTime offset);}转换DateTimeOffset为DateTime
在转换一个DateTimeOffset类型为DateTime类型时 可以使用如下几个属性
DateTime属性 返回一个指示为Unspecified的DateTime值
lishixinzhi/Article/program/net/201311/14875 很赞哦! (1038)
- 上一篇
altersqloracle oracle资料库中,想用alter语句给表exam增加一个日期时间型栏位sdate,应该怎么写?
oracle资料库中,想用alter语句给表exam增加一个日期时间型栏位 date,应该怎么写? oracle资料库中,想用alter语句给表exam增加一个日期时间型栏位 date,应该怎么写?a
- 下一篇
Excel日期格式转换 身份证在excel表格中应该怎么设定格式!
身份证在excel表格中应该怎么设定格式 身份证在excel表格中应该怎么设定格式输入身份证号时应先将单元格设定为文字格式,或输入时在前面加单引号。怎么设定excel表格身份证等格式?选中要输入的身份
相关文章
- by加时间点用什么时态 datefrom通常连用什么时态
- js如何格式化日期 获得系统当前时间日期和格式化时间
- 日期时间格式的书写 JS 时间格式转换
- db2时间戳转换日期格式 js时间戳怎么转成日期格式
- html显示当前日期时间 C#怎么获取当前的日期,并且时间为00:00:00的
- 获取今天日期 做一个android应用,需要获取本地真实日期时间,现在用time()获取的有时差?求正确程式码
- 属于日期时间型的数据类型是 使用.NET Framework中新的日期时间类型[6]
- datetime js怎么将日期字串转换成datetime物件
- java.util java中时间类Date和Calendar的使用
- date日期加一天 Mysql中时间日期使用date类型好还是bigint时间戳好
爱学记

微信收款码
支付宝收款码