當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET DateTimeOffset.Subtraction操作符代碼示例

本文整理匯總了VB.NET中System.DateTimeOffset.Subtraction操作符的典型用法代碼示例。如果您正苦於以下問題:VB.NET DateTimeOffset.Subtraction操作符的具體用法?VB.NET DateTimeOffset.Subtraction怎麽用?VB.NET DateTimeOffset.Subtraction使用的例子?那麽, 這裏精選的操作符代碼示例或許可以為您提供幫助。您也可以進一步了解該操作符所在System.DateTimeOffset的用法示例。


在下文中一共展示了DateTimeOffset.Subtraction操作符的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。

示例1: DateTimeOffset

Dim firstDate As New DateTimeOffset(#3/25/2008 6:00PM#, _
                                    New TimeSpan(-7, 0, 0))
Dim secondDate As New DateTimeOffset(#3/25/2008 6:00PM#, _
                                     New TimeSpan(-5, 0, 0))
Dim thirdDate As New DateTimeOffset(#2/28/2008 9:00AM#, _
                                    New TimeSpan(-7, 0, 0))
Dim difference As TimeSpan

difference = firstDate - secondDate
Console.WriteLine("({0}) - ({1}): {2} days, {3}:{4:d2}", _
                  firstDate.ToString(), _
                  secondDate.ToString(), _
                  difference.Days, _
                  difference.Hours, _
                  difference.Minutes)      
difference = firstDate - thirdDate
Console.WriteLine("({0}) - ({1}): {2} days, {3}:{4:d2}", _
                  firstDate.ToString(), _
                  secondDate.ToString(), _
                  difference.Days, _
                  difference.Hours, _
                  difference.Minutes)
開發者ID:VB.NET開發者,項目名稱:System,代碼行數:22,代碼來源:DateTimeOffset.Subtraction

輸出:

(3/25/2008 6:00:00 PM -07:00) - (3/25/2008 6:00:00 PM -05:00): 0 days, 2:00
(3/25/2008 6:00:00 PM -07:00) - (3/25/2008 6:00:00 PM -05:00): 26 days, 9:00

示例2: DateTimeOffset

Dim offsetDate As New DateTimeOffset(#12/3/2007 11:30AM#, _
                               New TimeSpan(-8, 0, 0)) 
Dim duration As New TimeSpan(7, 18, 0, 0)
Console.WriteLine(offsetDate - duration)    ' Displays 11/25/2007 5:30:00 PM -08:00
開發者ID:VB.NET開發者,項目名稱:System,代碼行數:4,代碼來源:DateTimeOffset.Subtraction


注:本文中的System.DateTimeOffset.Subtraction操作符示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。