元号の一覧をArrayListで返す

カテゴリ: VB.NET
投稿日時:2008/12/10 12:10:50
元号の一覧をArrayListで返す関数

Public Shared Function GetGengou() As ArrayList
    Dim calendar As System.Globalization.Calendar = New System.Globalization.JapaneseCalendar()
    Dim culture As System.Globalization.CultureInfo = New System.Globalization.CultureInfo("ja-JP")
    culture.DateTimeFormat.Calendar = calendar

    Dim dat As New DateTime(1900, 1, 1)
    Dim ht As New ArrayList

    While dat <= DateTime.Today

        Dim strGengou As String = dat.ToString("gyy/MM/dd", culture).Substring(0, dat.ToString("gyy/MM/dd", culture).Length - 8)
        If Not ht.Contains(strGengou) Then
            ht.Add(strGengou)
        End If
        dat = dat.AddDays(1)
    End While

    Return ht
End Function
このエントリーをはてなブックマークに追加


スポンサード リンク