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


VB.NET GregorianCalendar類代碼示例

本文整理匯總了VB.NET中System.Globalization.GregorianCalendar的典型用法代碼示例。如果您正苦於以下問題:VB.NET GregorianCalendar類的具體用法?VB.NET GregorianCalendar怎麽用?VB.NET GregorianCalendar使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: SamplesGregorianCalendar

' 導入命名空間
Imports System.Globalization

Public Class SamplesGregorianCalendar

   Public Shared Sub Main()

      ' Creates strings with punctuation and without.
      Dim strADPunc As [String] = "A.D."
      Dim strADNoPunc As [String] = "AD"
      Dim strCEPunc As [String] = "C.E."
      Dim strCENoPunc As [String] = "CE"

      ' Calls DTFI.GetEra for each culture that uses GregorianCalendar as the default calendar.
      Console.WriteLine("            ----- AD -----  ----- CE -----")
      Console.WriteLine("CULTURE     PUNC   NO PUNC  PUNC   NO PUNC  CALENDAR")
      Dim myCI As CultureInfo
      For Each myCI In  CultureInfo.GetCultures(CultureTypes.SpecificCultures)
         Console.Write("{0,-12}", myCI)
         Console.Write("{0,-7}{1,-9}", myCI.DateTimeFormat.GetEra(strADPunc), myCI.DateTimeFormat.GetEra(strADNoPunc))
         Console.Write("{0,-7}{1,-9}", myCI.DateTimeFormat.GetEra(strCEPunc), myCI.DateTimeFormat.GetEra(strCENoPunc))
         Console.Write("{0}", myCI.Calendar)
         Console.WriteLine()
      Next myCI

   End Sub

End Class


'This code produces the following output.  This output has been cropped for brevity.
'
'            ----- AD -----  ----- CE -----
'CULTURE     PUNC   NO PUNC  PUNC   NO PUNC  CALENDAR
'ar-SA       -1     -1       -1     -1       System.Globalization.HijriCalendar
'ar-IQ       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-EG       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-LY       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-DZ       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-MA       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-TN       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-OM       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-YE       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-SY       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-JO       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-LB       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-KW       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-AE       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-BH       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-QA       1      1        -1     -1       System.Globalization.GregorianCalendar
'bg-BG       1      1        -1     -1       System.Globalization.GregorianCalendar
'ca-ES       -1     -1       -1     -1       System.Globalization.GregorianCalendar
'zh-TW       -1     -1       -1     -1       System.Globalization.GregorianCalendar
'zh-CN       -1     -1       -1     -1       System.Globalization.GregorianCalendar
'zh-HK       -1     -1       -1     -1       System.Globalization.GregorianCalendar
'zh-SG       1      1        -1     -1       System.Globalization.GregorianCalendar
'zh-MO       1      1        -1     -1       System.Globalization.GregorianCalendar
'cs-CZ       -1     -1       -1     -1       System.Globalization.GregorianCalendar
'da-DK       1      1        -1     -1       System.Globalization.GregorianCalendar
開發者ID:VB.NET開發者,項目名稱:System.Globalization,代碼行數:59,代碼來源:GregorianCalendar

示例2: Main

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

Module Example
   Public Sub Main()
      Thread.CurrentThread.CurrentCulture = New CultureInfo("da-DK")
      
      Dim jc As New JulianCalendar()
      Dim lastDate As New DateTime(1700, 2, 18, jc)
      Console.WriteLine("Last date (Gregorian): {0:d}", lastDate)
      Console.WriteLine("Last date (Julian): {0}-{1}-{2}", jc.GetDayOfMonth(lastDate),
                        jc.GetMonth(lastDate), jc.GetYear(lastDate))
      Console.WriteLine()
      
      Dim firstDate As DateTime = lastDate.AddDays(1)
      Console.WriteLine("First date (Gregorian): {0:d}", firstDate)
      Console.WriteLine("First date (Julian): {0}-{1}-{2}",  jc.GetDayOfMonth(firstDate),
                        jc.GetMonth(firstDate), jc.GetYear(firstDate))
   End Sub
End Module
開發者ID:VB.NET開發者,項目名稱:System.Globalization,代碼行數:21,代碼來源:GregorianCalendar

輸出:

Last date (Gregorian): 28-02-1700
Last date (Julian): 18-2-1700

First date (Gregorian): 01-03-1700
First date (Julian): 19-2-1700


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