更新:2007 年 11 月
命名空间:
System.Globalization 程序集:
mscorlib(在 mscorlib.dll 中)
<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Class JapaneseCalendar _
Inherits Calendar
Dim instance As JapaneseCalendar
[SerializableAttribute]
[ComVisibleAttribute(true)]
public class JapaneseCalendar : Calendar
[SerializableAttribute]
[ComVisibleAttribute(true)]
public ref class JapaneseCalendar : public Calendar
/** @attribute SerializableAttribute */
/** @attribute ComVisibleAttribute(true) */
public class JapaneseCalendar extends Calendar
public class JapaneseCalendar extends Calendar
除纪元年份不同外,日本历(又称为 Wareki 历)与公历完全一样。
日本历将每个皇帝的统治时期标识为一个纪元。当前纪元是平成纪元,始于公历 1989 年。纪元名称通常显示在年份前。例如,公历 2001 年相当于日本历平成 13 年。请注意,纪元的第一年称为“元年”。因此,公历 1989 年是日本历的平成元年。
此类如下所示向纪元分配数值:
GetEra 值 | 纪元名称 | 纪元缩写 | 公历日期 |
|---|
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 年 1 月 1 日至 1912 年 7 月 29 日 |
此类只处理日本明治元年一月一日(公历 1868 年 1 月 1 日)以后的日期。尽管日本历在 Meiji 6 年(公历 1873 年)从阴历转换为阳历,但此实现仅基于阳历。
日本历中的闰年与公历中的相同闰年对应。公历中的闰年定义为:除可被 100 整除的年份外,可以被 4 整除的公历年份。但是,可以被 400 整除的公历年份也是闰年。平年有 365 天,闰年有 366 天。
日本历有 12 个月,每个月有 28 到 31 天不等:
GetMonth 值 | 月份 | 简体中文 | 平年中的天数 | 闰年中的天数 |
|---|
1 | 1 月 (Ichigatsu) | 1 月 | 31 | 31 |
2 | 2 月 (Nigatsu) | 2 月 | 28 | 29 |
3 | 3 月 (Sangatsu) | 3 月 | 31 | 31 |
4 | 4 月 (Shigatsu) | 4 月 | 30 | 30 |
5 | 5 月 (Gogatsu) | 5 月 | 31 | 31 |
6 | 6 月 (Rokugatsu) | 6 月 | 30 | 30 |
7 | 7 月 (Shichigatsu) | 7 月 | 31 | 31 |
8 | 8 月 (Hachigatsu) | 8 月 | 31 | 31 |
9 | 9 月 (Kugatsu) | 9 月 | 30 | 30 |
10 | 10 月 (Juugatsu) | 10 月 | 31 | 31 |
11 | 11 月 (Juuichigatsu) | 11 月 | 30 | 30 |
12 | 12 月 (Juunigatsu) | 12 月 | 31 | 31 |
Nigatsu 相当于公历中的 2 月,闰年中为 29 天,平年中为 28 天。
公历中日期公元 2001 年 1 月 1 日相当于日本历中平成 13 年 Ichigatsu 的第 1 天。
如果应用程序使用了 JapaneseCalendar 类,DateTime..::.Parse 便可以识别年份前面的纪元缩写。该缩写可以是不区分大小写的单字符拉丁字母缩写,或是单字符的日语汉字缩写。
每个 CultureInfo 对象都支持一组日历。Calendar 属性返回区域性的默认日历,OptionalCalendars 属性返回一个包含区域性所支持的所有日历的数组。若要更改 CultureInfo 所使用的日历,应用程序应将 CultureInfo..::.DateTimeFormat 的 Calendar 属性设置为新的 Calendar。
System..::.Object
System.Globalization..::.Calendar
System.Globalization..::.JapaneseCalendar
此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。
Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
.NET Framework
受以下版本支持:3.5、3.0、2.0、1.1、1.0
.NET Compact Framework
受以下版本支持:3.5、2.0、1.0
XNA Framework
受以下版本支持:2.0、1.0
参考