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
'

備註

日曆可辨識每個紀元的重新簽署。 這兩個最近的紀元是 Heisei 紀元,從公曆 1989 年開始,而 Reiwa 紀元則從公曆年份 2019 開始。 紀元名稱通常會顯示在年份之前。 例如,公曆年 2001 年是日曆年份 Heisei 13。 請注意,紀元的第一年稱為 “Gannen”。因此,公曆 1989 年是日曆年份 Heisei Gannen。

重要

日本曆法的紀元是以天皇的統治為基礎,因此有變更是正常的。 例如,2019 年 5 月 1 日之後,JapaneseCalendarJapaneseLunisolarCalendar 中將開始使用「令和」。 此變更對使用這些日曆的所有應用程式都有影響。 如需詳細資訊,以及判斷您的應用程式是否受到影響,請參閱 在 .NET 中處理日曆的新紀元。 如需在 Windows 系統上測試應用程式以確保其對紀元變更整備的資訊,請參閱 為日文紀元變更準備您的應用程式。 如需支援多個紀元之行事歷的 .NET 功能,以及使用支援多個紀元的行事歷時的最佳做法,請參閱 使用紀元。

此類別會將數位指派給紀元,如下所示:

GetEra 值 紀元名稱 紀元縮寫 公曆日期
5 令和 (Reiwa) 管理與 (R、r) 2019年5月1日至簡報
4 平成 (Heisei) 平 (H, h) 1989 年 1 月 8 日至簡報
3 和 (Showa) (S, s) 1926 年 12 月 25 日到 1989 年 1 月 7 日
2 大正 (Taisho) 大 (T, t) 1912 年 7 月 30 日到 1926 年 12 月 24 日
1 (Meiji) 明 (M, m) 1868 年 9 月 8 日到 1912 年 7 月 29 日

此類別會處理 Meiji 1 年 9 月 8 日 (公曆 1868 年 1 月 1 日) 日期。 雖然日曆已從月曆切換到公曆 6 (1873 年公曆) 的日曆,但此實作僅以太陽能歷為基礎。

注意

未來應該新增其他紀元,應用程式可能會遇到超過日曆的五個預期紀元。 您的應用程式應該經過測試,以確保它們能夠繼續在這類事件中運作;請參閱 日曆的紀元處理

適用於

另請參閱