本文整理匯總了VB.NET中System.Globalization.JapaneseCalendar.ToDateTime方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET JapaneseCalendar.ToDateTime方法的具體用法?VB.NET JapaneseCalendar.ToDateTime怎麽用?VB.NET JapaneseCalendar.ToDateTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。
在下文中一共展示了JapaneseCalendar.ToDateTime方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Program
' 導入命名空間
Imports System.Globalization
Module Program
Dim cal As Calendar
Dim jaJp As CultureInfo
Public Sub Main()
cal = New JapaneseCalendar()
jaJp = New CultureInfo("ja-JP")
jaJp.DateTimeFormat.Calendar = cal
Dim date1 = cal.ToDateTime(2,1,1,0,0,0,0,JapaneseCalendar.CurrentEra)
Console.WriteLine($"Japanese calendar date: {date1.ToString("D", jaJp)}, " +
$"Gregorian calendar date: {date1.ToString("D", CultureInfo.InvariantCulture)}")
Dim date2 = cal.ToDateTime(6,11,7,0,0,0,0,GetEraIndex("大正"))
Console.WriteLine($"Japanese calendar date: {date2.ToString("D", jaJp)}, " +
$"Gregorian calendar date: {date2.ToString("D", CultureInfo.InvariantCulture)}")
End Sub
Private Function GetEraIndex(eraName As String) As Integer
For Each ctr in cal.Eras
If jaJp.DateTimeFormat.GetEraName(ctr) = eraName Then Return ctr
Next
Return 0
End Function
End Module
輸出:
Japanese calendar date: 平成2年1月1日, Gregorian calendar date: Monday, 01 January 1990 Japanese calendar date: 大正6年11月7日, Gregorian calendar date: Wednesday, 07 November 1917