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


VB.NET DateTime.Year屬性代碼示例

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


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

示例1:

Dim moment As New System.DateTime(1999, 1, 13, 3, 57, 32, 11)

' Year gets 1999.
Dim year As Integer = moment.Year

' Month gets 1 (January).
Dim month As Integer = moment.Month

' Day gets 13.
Dim day As Integer = moment.Day

' Hour gets 3.
Dim hour As Integer = moment.Hour

' Minute gets 57.
Dim minute As Integer = moment.Minute

' Second gets 32.
Dim second As Integer = moment.Second

' Millisecond gets 11.
Dim millisecond As Integer = moment.Millisecond
開發者ID:VB.NET開發者,項目名稱:System,代碼行數:22,代碼來源:DateTime.Year

示例2: YearMethodExample

' 導入命名空間
Imports System.Globalization
Imports System.Threading

Module YearMethodExample
   Public Sub Main()
      ' Initialize date variable and display year
      Dim date1 As Date = #01/01/2008 6:32AM#
      Console.WriteLine(date1.Year)       ' Displays 2008
      
      ' Set culture to th-TH
      Thread.CurrentThread.CurrentCulture = New CultureInfo("th-TH")
      Console.WriteLine(date1.Year)        ' Displays 2008
      
      ' display year using current culture's calendar 
      Dim thaiCalendar As Calendar = CultureInfo.CurrentCulture.Calendar
      Console.WriteLine(thaiCalendar.GetYear(date1))    ' Displays 2551
      
      ' display year using Persian calendar
      Dim persianCalendar As New PersianCalendar()
      Console.WriteLine(persianCalendar.GetYear(date1))  ' Displays 1386 
   End Sub
End Module
開發者ID:VB.NET開發者,項目名稱:System,代碼行數:23,代碼來源:DateTime.Year

示例3: MainClass

' 導入命名空間
Imports System

Public Class MainClass

    Shared Sub Main(ByVal args As String())
       Dim currentTime as System.DateTime = System.DateTime.Now
       Console.WriteLine("currentTime Year :" & currentTime.Year)
       Console.WriteLine("currentTime Month:" &  currentTime.Month)
       Console.WriteLine("currentTime Date:" & currentTime.Date)
       Console.WriteLine("currentTime Hour:" & currentTime.Hour)
       Console.WriteLine("currentTime Minute:" & currentTime.Minute)
       Console.WriteLine("currentTime Second:" & currentTime.Second)
    End Sub
End Class
開發者ID:VB程序員,項目名稱:System,代碼行數:15,代碼來源:DateTime.Year


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