JapaneseCalendar.Eras 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取 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
'
注解
日本日历承认每个皇帝统治的一个时代。 最近两个时代是海西时代,从1989年公历年开始,从2019年公历年开始的雷瓦时代。 纪元名称通常显示在年份前。 例如,2001 年公历年是日本日历年 Heisei 13。 请注意,时代的第一年被称为“甘宁”。 因此,1989年公历年是日本历年海西甘宁。
重要
日本历法中的年号是根据天皇统治来命名的,因此预计会发生变化。 例如,2019 年 5 月 1 日在 JapaneseCalendar 和 JapaneseLunisolarCalendar 中标志着令和年号的开始。 这种年号的变化会影响使用这些日历的所有应用程序。 有关详细信息以及如何确定应用程序是否受影响,请参阅在 .net 中的日式日历中处理新时代。 若要了解如何在 Windows 系统上测试应用程序以确保其应用程序更改的就绪性,请参阅准备应用程序以进行日本时代更改。 对于 .NET 中支持多个纪元的日历的功能,以及在处理支持多个纪元的日历时的最佳做法,请参阅使用 纪元。
此类将数字分配给纪元,如下所示:
GetEra 值 | 纪元名称 | 纪元缩写 | 公历日期 |
---|---|---|---|
5 | 令和 (Reiwa) | 令和 (R、 r) | 2019 年 5 月 1 日至今 |
4 | 平成 (海西) | 平 (H、h) | 1989年1月8日至今 |
3 | 昭和 (Showa) | 昭 (S, s) | 1926年12月25日至1989年1月7日 |
2 | 大正 (太浩) | 大 (T,t) | 1912 年 7 月 30 日至 1926 年 12 月 24 日 |
1 | 明治 (梅吉) | 明 (M、m) | 1868 年 9 月 8 日至 1912 年 7 月 29 日 |
此类处理 1868 年 1 月 1 (日 1868 年 9 月 8 日在公历) 年 9 月 8 日之间的日期。 虽然日本日历从农历切换到了梅吉六 (1873年公历) 的一年,但这一实现仅基于太阳历。
备注
如果将来添加其他纪元,应用程序可能会遇到超过日本日历的预期五个时代。 应测试应用程序,以确保它们继续在此类事件中工作;请参阅 日本日历的纪元处理。