本文整理汇总了VB.NET中System.DateTimeOffset.ToLocalTime方法的典型用法代码示例。如果您正苦于以下问题:VB.NET DateTimeOffset.ToLocalTime方法的具体用法?VB.NET DateTimeOffset.ToLocalTime怎么用?VB.NET DateTimeOffset.ToLocalTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.DateTimeOffset
的用法示例。
在下文中一共展示了DateTimeOffset.ToLocalTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: DateTimeOffset
' Local time changes on 3/11/2007 at 2:00 AM
Dim originalTime, localTime As DateTimeOffset
originalTime = New DateTimeOffset(#03/11/2007 3:00AM#, _
New TimeSpan(-6, 0, 0))
localTime = originalTime.ToLocalTime()
Console.WriteLine("Converted {0} to {1}.", originalTime.ToString(), _
localTime.ToString())
originalTime = New DateTimeOffset(#03/11/2007 4:00AM#, _
New TimeSpan(-6, 0, 0))
localTime = originalTime.ToLocalTime()
Console.WriteLine("Converted {0} to {1}.", originalTime.ToString(), _
localTime.ToString())
' Define a summer UTC time
originalTime = New DateTimeOffset(#6/15/2007 8:00AM#, _
TimeSpan.Zero)
localTime = originalTime.ToLocalTime()
Console.WriteLine("Converted {0} to {1}.", originalTime.ToString(), _
localTime.ToString())
' Define a winter time
originalTime = New DateTimeOffset(#11/30/2007 2:00PM#, _
New TimeSpan(3, 0, 0))
localTime = originalTime.ToLocalTime()
Console.WriteLine("Converted {0} to {1}.", originalTime.ToString(), _
localTime.ToString())
输出:
Converted 3/11/2007 3:00:00 AM -06:00 to 3/11/2007 1:00:00 AM -08:00. Converted 3/11/2007 4:00:00 AM -06:00 to 3/11/2007 3:00:00 AM -07:00. Converted 6/15/2007 8:00:00 AM +00:00 to 6/15/2007 1:00:00 AM -07:00. Converted 11/30/2007 2:00:00 PM +03:00 to 11/30/2007 3:00:00 AM -08:00.