本文整理汇总了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)
输出:
(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