本文整理汇总了VB.NET中System.Globalization.Calendar.GetDayOfYear方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Calendar.GetDayOfYear方法的具体用法?VB.NET Calendar.GetDayOfYear怎么用?VB.NET Calendar.GetDayOfYear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Globalization.Calendar
的用法示例。
在下文中一共展示了Calendar.GetDayOfYear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Main
' 导入命名空间
Imports System.Globalization
Public Class SamplesCalendar
Public Shared Sub Main()
' Sets a DateTime to April 3, 2002 of the Gregorian calendar.
Dim myDT As New DateTime(2002, 4, 3, New GregorianCalendar())
' Uses the default calendar of the InvariantCulture.
Dim myCal As Calendar = CultureInfo.InvariantCulture.Calendar
' Displays the values of the DateTime.
Console.WriteLine("April 3, 2002 of the Gregorian calendar:")
DisplayValues(myCal, myDT)
' Adds 5 to every component of the DateTime.
myDT = myCal.AddYears(myDT, 5)
myDT = myCal.AddMonths(myDT, 5)
myDT = myCal.AddWeeks(myDT, 5)
myDT = myCal.AddDays(myDT, 5)
myDT = myCal.AddHours(myDT, 5)
myDT = myCal.AddMinutes(myDT, 5)
myDT = myCal.AddSeconds(myDT, 5)
myDT = myCal.AddMilliseconds(myDT, 5)
' Displays the values of the DateTime.
Console.WriteLine("After adding 5 to each component of the DateTime:")
DisplayValues(myCal, myDT)
End Sub
Public Shared Sub DisplayValues(myCal As Calendar, myDT As DateTime)
Console.WriteLine(" Era: {0}", myCal.GetEra(myDT))
Console.WriteLine(" Year: {0}", myCal.GetYear(myDT))
Console.WriteLine(" Month: {0}", myCal.GetMonth(myDT))
Console.WriteLine(" DayOfYear: {0}", myCal.GetDayOfYear(myDT))
Console.WriteLine(" DayOfMonth: {0}", myCal.GetDayOfMonth(myDT))
Console.WriteLine(" DayOfWeek: {0}", myCal.GetDayOfWeek(myDT))
Console.WriteLine(" Hour: {0}", myCal.GetHour(myDT))
Console.WriteLine(" Minute: {0}", myCal.GetMinute(myDT))
Console.WriteLine(" Second: {0}", myCal.GetSecond(myDT))
Console.WriteLine(" Milliseconds: {0}", myCal.GetMilliseconds(myDT))
Console.WriteLine()
End Sub
End Class
输出:
April 3, 2002 of the Gregorian calendar: Era: 1 Year: 2002 Month: 4 DayOfYear: 93 DayOfMonth: 3 DayOfWeek: Wednesday Hour: 0 Minute: 0 Second: 0 Milliseconds: 0 After adding 5 to each component of the DateTime: Era: 1 Year: 2007 Month: 10 DayOfYear: 286 DayOfMonth: 13 DayOfWeek: Saturday Hour: 5 Minute: 5 Second: 5 Milliseconds: 5