本文整理匯總了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.