JapaneseCalendar.Eras プロパティ

定義

JapaneseCalendar における時代 (年号) のリストを取得します。

public:
 virtual property cli::array <int> ^ Eras { cli::array <int> ^ get(); };
public override int[] Eras { get; }
member this.Eras : int[]
Public Overrides ReadOnly Property Eras As Integer()

プロパティ値

Int32[]

時代 (年号) を JapaneseCalendar で表す整数の配列。

次の例では、プロパティに含まれる値を Eras 表示します。

using namespace System;
using namespace System::Globalization;
int main()
{
   
   // Creates and initializes a JapaneseCalendar.
   JapaneseCalendar^ myCal = gcnew JapaneseCalendar;
   
   // Displays the values in the Eras property.
   for ( int i = 0; i < myCal->Eras->Length; i++ )
   {
      Console::WriteLine( "Eras[ {0}] = {1}", i, myCal->Eras[ i ] );

   }
}

/*
This code produces the following output.

Eras->Item[0] = 4
Eras->Item[1] = 3
Eras->Item[2] = 2
Eras->Item[3] = 1

*/
using System;
using System.Globalization;

public class SamplesJapaneseCalendar  {

   public static void Main()  {

      // Creates and initializes a JapaneseCalendar.
      JapaneseCalendar myCal = new JapaneseCalendar();

      // Displays the values in the Eras property.
      for ( int i = 0; i < myCal.Eras.Length; i++ )  {
         Console.WriteLine( "Eras[{0}] = {1}", i, myCal.Eras[i] );
      }
   }
}

/*
This code produces the following output.

Eras[0] = 4
Eras[1] = 3
Eras[2] = 2
Eras[3] = 1

*/
Imports System.Globalization

Public Class SamplesJapaneseCalendar

   Public Shared Sub Main()

      ' Creates and initializes a JapaneseCalendar.
      Dim myCal As New JapaneseCalendar()

      ' Displays the values in the Eras property.
      Dim i As Integer
      For i = 0 To myCal.Eras.Length - 1
         Console.WriteLine("Eras[{0}] = {1}", i, myCal.Eras(i))
      Next i

   End Sub

End Class

'This code produces the following output.
'
'Eras[0] = 4
'Eras[1] = 3
'Eras[2] = 2
'Eras[3] = 1
'

注釈

和暦では、天皇の代ごとに 1 つの時代 (年号) を認識します。 最近の2つの時代は、グレゴリオ暦1989年から始まる平成と、2019年のグレゴリオ暦から始まる令和時代です。 元号の名前は通常、年の前に表示されます。 たとえば、グレゴリオ暦の 2001 年は和暦の平成 13 年です。 時代 (年号) の最初の年が「元年」と呼ばれることに注意してください。 そのため、グレゴリオ暦の 1989 年は和暦の平成元年でした。

重要

和暦の時代 (年号) は天皇の代に基づいているため、変更されることが予想されます。 たとえば、JapaneseCalendarJapaneseLunisolarCalendar において、2019 年 5 月 1 日から令和時代が始まることになりました。 このような時代 (年号) の変更は、これらのカレンダーを使用するすべてのアプリケーションに影響します。 詳細およびアプリケーションが影響を受けるかどうかを判断する方法については、「 .net の日本語カレンダーでの新しい時代 (年号) の処理」を参照してください。 Windows システムでアプリケーションをテストして、時代 (年号) の変化に対応できるようにする方法については、「日本語時代 (年号) の変更に備えてアプリケーションを準備する」を参照してください。 複数の時代 (年号) を含む暦をサポートする .NET の機能について、および複数の時代 (年号) をサポートする予定表を操作する場合のベストプラクティスについては、「時代と作業

このクラスは、次のように年号に数値を割り当てます。

GetEra 値 Era 名 時代 (年号) の省略形 グレゴリオ暦の日付
5 令和 (レイワ) 令和 (R,r) 2019 年 5 月 1日から現在まで
4 平成 (Heisei) 平 (H, h) 1989 年 1 月 8 日から 2019 年 4 月 30 日まで
3 昭和 (Showa) 昭 (S、s) 1926 年 12 月 25 日から 1989 年 1 月 7 日まで
2 大正 大 (T、t) 1912 年 7 月 30 日から 1926 年 12 月 24 日まで
1 明治 (Meiji) 明 (M,m) 1868 年 9 月 8 日から 1912 年 7 月 29 日まで

このクラスは、明治1年(グレゴリオ暦の1868年1月1日)の9月8日からの日付を処理します。 和暦は明治 6 年 (グレゴリオ暦の 1873 年) に太陰暦から太陽暦に切り替わりましたが、この実装は太陽暦のみに基づいています。

注意

今後年号を追加する場合、アプリケーションは、日本のカレンダーで予想される 5 つの時代 (年号) を超える可能性があります。 アプリケーションがこのようなイベントで引き続き動作することを確認するために、アプリケーションをテストする必要があります。 日本語カレンダーの時代 (年号処理) を参照してください。

適用対象

こちらもご覧ください