JapaneseCalendar 类

定义

表示日本历。Represents the Japanese calendar.

public ref class JapaneseCalendar : System::Globalization::Calendar
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class JapaneseCalendar : System.Globalization.Calendar
type JapaneseCalendar = class
    inherit Calendar
Public Class JapaneseCalendar
Inherits Calendar
继承
JapaneseCalendar
属性

注解

日语日历 (也称为 Wareki 日历) 的工作方式与公历完全相同, 不同之处在于年和纪元不同。The Japanese calendar, which is also known as the Wareki calendar, works exactly like the Gregorian calendar, except that the year and era are different.

备注

有关使用 .net 中的JapaneseCalendar类和其他 calendar 类的信息, 请参阅使用日历For information about using the JapaneseCalendar class and the other calendar classes in .NET, see Working with Calendars.

日本历可识别每个高层的 reign 的一个纪元。The Japanese calendar recognizes one era for every emperor's reign. 最新的两个纪元是 Heisei 纪元, 从公历年1989开始, 以公历年2019开头。The two most recent eras are the Heisei era, beginning in the Gregorian calendar year 1989, and the Reiwa era, beginning in the Gregorian calendar year 2019. 纪元名称通常显示在年份之前。The era name is typically displayed before the year. 例如, 公历年2001是日本历年 Heisei 13。For example, the Gregorian calendar year 2001 is the Japanese calendar year Heisei 13. 请注意, 纪元的第一年名为 "Gannen"。Note that the first year of an era is called "Gannen." 因此, 公历年1989是日本历年的 Heisei Gannen。Therefore, the Gregorian calendar year 1989 was the Japanese calendar year Heisei Gannen. 默认情况下, 在结果字符串中使用指定的日期和时间格式字符串 (如 "D"、"F" 和 "Y") 的格式设置操作, 而不是 "1"。By default, formatting operations with specified date and time format strings, such as "D", "F", and "Y", output Gannen rather than "1" in the result string.

重要

日本历法中的年号是根据天皇统治来命名的,因此预计会发生变化。Eras in the Japanese calendars are based on the emperor's reign and are therefore expected to change. 例如,2019 年 5 月 1 日在 JapaneseCalendarJapaneseLunisolarCalendar 中标志着令和年号的开始。For example, May 1, 2019 marked the beginning of the Reiwa era in the JapaneseCalendar and JapaneseLunisolarCalendar. 这种年号的变化会影响使用这些日历的所有应用程序。Such a change of era affects all applications that use these calendars. 请参阅 Handling a new era in the Japanese calendar in .NET(使用 .NET 处理日语日历中的新元号),了解详细信息并确定是否会影响你的应用程序。See Handling a new era in the Japanese calendar in .NET for more information and to determine whether your applications are affected. 请参阅针对日语元号更改准备应用程序,了解有关在 Windows 系统上测试应用程序以确保针对元号更改的准备情况信息。See Prepare your application for the Japanese era change for information on testing your applications on Windows systems to ensure their readiness for the era change. 有关 .Net 中支持多个年号日历的功能,以及在使用支持多个年号的日历时的最佳做法,请参阅使用年号See Working with eras for features in .NET that support calendars with multiple eras and for best practices when working with calendars that support multiple eras.

此类将编号分配给纪元, 如下所示:This class assigns numbers to the eras as follows:

GetEra 值GetEra value 纪元名称Era Name 纪元缩写Era Abbreviation 公历日期Gregorian Dates
55 令和 (Reiwa)令和 (Reiwa) 令和 (R, r)令和 (R, r) 5月1日, 2019May 1, 2019 to present
44 平成 (Heisei)平成 (Heisei) 平 (H, h)平 (H, h) 1989年1月8日至4月30日, 2019January 8, 1989 to April 30, 2019
33 昭和 (Showa)昭和 (Showa) 昭 (S, s)昭 (S, s) 12月25日, 1926 到1月7日, 1989December 25, 1926 to January 7, 1989
22 大正 (Taisho)大正 (Taisho) 大 (T, t)大 (T, t) 1912年7月30日, 1926July 30, 1912 to December 24, 1926
11 明治 (Meiji)明治 (Meiji) 明 (M, m)明 (M, m) 9月8日1868到7月29日, 1912September 8, 1868 to July 29, 1912

此类处理 Meiji 1 年9月8日 (公历, 1868 年9月8日) 的日期。This class handles dates from September 8 in the year Meiji 1 (in the Gregorian calendar, September 8, 1868). 尽管日语日历已从阴历日历切换到 Meiji 6 年 (公历日历的1873年) 的阳历, 但此实现仅基于阳历。Although the Japanese calendar was switched from a lunar calendar to a solar calendar in the year Meiji 6 (1873 of the Gregorian calendar), this implementation is based on the solar calendar only.

日本日历中的闰年对应于公历中的相同闰年。Leap years in the Japanese calendar correspond to the same leap years in the Gregorian calendar. 公历中的闰年定义为可被四整除的公历年份, 但它可被100整除。A leap year in the Gregorian calendar is defined as a Gregorian year that is evenly divisible by four, except if it is divisible by 100. 但是, 400 可以整除的公历年是闰年。However, Gregorian years that are divisible by 400 are leap years. 一个常见年份有365天, 闰年有366天。A common year has 365 days and a leap year has 366 days.

日语日历包含12个月, 每个月28到31天:The Japanese calendar has 12 months with 28 to 31 days each:

GetMonth 值GetMonth value 月份Month 英语English 常见年份中的天数Days in common years 闰年中的天数Days in leap years
11 1月 (Ichigatsu)1月 (Ichigatsu) January 3131 3131
22 2月 (Nigatsu)2月 (Nigatsu) 2009February 2828 2929
33 3月 (Sangatsu)3月 (Sangatsu) 3 月March 3131 3131
44 4月 (Shigatsu)4月 (Shigatsu) 四月份April 3030 3030
55 5月 (Gogatsu)5月 (Gogatsu) 有助于May 3131 3131
66 6月 (Rokugatsu)6月 (Rokugatsu) 6 月June 3030 3030
77 7月 (Shichigatsu)7月 (Shichigatsu) 7 月July 3131 3131
88 8月 (Hachigatsu)8月 (Hachigatsu) 2004August 3131 3131
99 9月 (Kugatsu)9月 (Kugatsu) 九月份September 3030 3030
1010 10月 (Juugatsu)10月 (Juugatsu) 2004October 3131 3131
1111 11月 (Juuichigatsu)11月 (Juuichigatsu) November 3030 3030
1212 12月 (Juunigatsu)12月 (Juunigatsu) 月份December 3131 3131

Nigatsu (相当于二月份的公历月) 在闰年中有29天, 在常见年份中有28天。Nigatsu, which is equivalent to the Gregorian calendar month of February, has 29 days during leap years and 28 during common years.

日期公元2001年1月1日The date January 1, 2001 A.D. 在公历中, 这相当于日本历年 Heisei 13 年中 Ichigatsu 的第一天。in the Gregorian calendar is equivalent to the first day of Ichigatsu in the year Heisei 13 in the Japanese calendar.

如果是日本区域性的当前日历, DateTime.Parse则识别年份前面的纪元缩写。 JapaneseCalendarIf the JapaneseCalendar is the current calendar of the Japanese culture, DateTime.Parse recognizes the era abbreviations in front of the year. 缩写词为不区分大小写的单字符拉丁字母缩写或单字符日文汉字缩写形式。The abbreviation is either the single-character case-insensitive Latin alphabet abbreviation or the single-character Kanji abbreviation. x: system.string% 2A? displayProperty = Namewithtype> > 还将 "1" 或 "Gannen" (元年) 识别为纪元的第一年。xref:System.DateTime.Parse%2A?displayProperty=nameWithType> also recognizes either "1" or Gannen (元年) as the first year of an era.

CultureInfo个对象都支持一组日历。Each CultureInfo object supports a set of calendars. 属性返回区域性的默认日历, OptionalCalendars属性返回一个数组, 该数组包含该区域性支持的所有日历。 CalendarThe Calendar property returns the default calendar for the culture, and the OptionalCalendars property returns an array containing all the calendars supported by the culture. 若要更改使用CultureInfo的日历, 请DateTimeFormatInfo.Calendar将属性设置为新Calendar的。To change the calendar used by a CultureInfo, set the DateTimeFormatInfo.Calendar property to a new Calendar.

构造函数

JapaneseCalendar()

初始化 JapaneseCalendar 类的新实例。Initializes a new instance of the JapaneseCalendar class.

字段

CurrentEra

表示当前日历的当前纪元。Represents the current era of the current calendar. 字段的值为 0。The value of this field is 0.

(继承自 Calendar)

属性

AlgorithmType

获取一个值,该值指示当前日历是阳历、阴历还是二者的组合。Gets a value that indicates whether the current calendar is solar-based, lunar-based, or a combination of both.

DaysInYearBeforeMinSupportedYear

获取 MinSupportedDateTime 属性指定的年份之前的年中天数。Gets the number of days in the year that precedes the year that is specified by the MinSupportedDateTime property.

(继承自 Calendar)
Eras

获取 JapaneseCalendar 中的纪元列表。Gets the list of eras in the JapaneseCalendar.

IsReadOnly

获取一个值,该值指示此 Calendar 对象是否为只读。Gets a value indicating whether this Calendar object is read-only.

(继承自 Calendar)
MaxSupportedDateTime

获取当前 JapaneseCalendar 对象支持的最晚日期和时间。Gets the latest date and time supported by the current JapaneseCalendar object.

MinSupportedDateTime

获取当前 JapaneseCalendar 对象支持的最早日期和时间。Gets the earliest date and time supported by the current JapaneseCalendar object.

TwoDigitYearMax

获取或设置可以用两位数年份表示的 100 年范围内的最后一年。Gets or sets the last year of a 100-year range that can be represented by a 2-digit year.

方法

AddDays(DateTime, Int32)

返回与指定 DateTime 相距指定天数的 DateTimeReturns a DateTime that is the specified number of days away from the specified DateTime.

(继承自 Calendar)
AddHours(DateTime, Int32)

返回与指定 DateTime 相距指定小时数的 DateTimeReturns a DateTime that is the specified number of hours away from the specified DateTime.

(继承自 Calendar)
AddMilliseconds(DateTime, Double)

返回与指定 DateTime 相距指定毫秒数的 DateTimeReturns a DateTime that is the specified number of milliseconds away from the specified DateTime.

(继承自 Calendar)
AddMinutes(DateTime, Int32)

返回与指定 DateTime 相距指定分钟数的 DateTimeReturns a DateTime that is the specified number of minutes away from the specified DateTime.

(继承自 Calendar)
AddMonths(DateTime, Int32)

返回与指定 DateTime 相距指定月数的 DateTimeReturns a DateTime that is the specified number of months away from the specified DateTime.

AddSeconds(DateTime, Int32)

返回与指定 DateTime 相距指定秒数的 DateTimeReturns a DateTime that is the specified number of seconds away from the specified DateTime.

(继承自 Calendar)
AddWeeks(DateTime, Int32)

返回与指定 DateTime 相距指定周数的 DateTimeReturns a DateTime that is the specified number of weeks away from the specified DateTime.

(继承自 Calendar)
AddYears(DateTime, Int32)

返回与指定 DateTime 相距指定年数的 DateTimeReturns a DateTime that is the specified number of years away from the specified DateTime.

Clone()

创建表示当前 Calendar 对象副本的新对象。Creates a new object that is a copy of the current Calendar object.

(继承自 Calendar)
Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetDayOfMonth(DateTime)

返回指定 DateTime 中的月中日期。Returns the day of the month in the specified DateTime.

GetDayOfWeek(DateTime)

返回指定 DateTime 中的周中日期。Returns the day of the week in the specified DateTime.

GetDayOfYear(DateTime)

返回指定 DateTime 中的日期是该年中的第几天。Returns the day of the year in the specified DateTime.

GetDaysInMonth(Int32, Int32)

返回当前纪元的指定月份和年份中的天数。Returns the number of days in the specified month and year of the current era.

(继承自 Calendar)
GetDaysInMonth(Int32, Int32, Int32)

返回指定纪元中指定年份的指定月份中的天数。Returns the number of days in the specified month in the specified year in the specified era.

GetDaysInYear(Int32)

返回当前纪元中指定年份的天数。Returns the number of days in the specified year of the current era.

(继承自 Calendar)
GetDaysInYear(Int32, Int32)

返回指定纪元中指定年份的天数。Returns the number of days in the specified year in the specified era.

GetEra(DateTime)

返回指定 DateTime 中的纪元。Returns the era in the specified DateTime.

GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetHour(DateTime)

返回指定 DateTime 中的小时值。Returns the hours value in the specified DateTime.

(继承自 Calendar)
GetLeapMonth(Int32)

计算指定年份的闰月。Calculates the leap month for a specified year.

(继承自 Calendar)
GetLeapMonth(Int32, Int32)

计算指定纪元年份的闰月。Calculates the leap month for a specified year and era.

GetMilliseconds(DateTime)

返回指定 DateTime 中的毫秒值。Returns the milliseconds value in the specified DateTime.

(继承自 Calendar)
GetMinute(DateTime)

返回指定 DateTime 中的分钟值。Returns the minutes value in the specified DateTime.

(继承自 Calendar)
GetMonth(DateTime)

返回指定 DateTime 中的月份。Returns the month in the specified DateTime.

GetMonthsInYear(Int32)

返回当前纪元中指定年份的月数。Returns the number of months in the specified year in the current era.

(继承自 Calendar)
GetMonthsInYear(Int32, Int32)

返回指定纪元中指定年份的月数。Returns the number of months in the specified year in the specified era.

GetSecond(DateTime)

返回指定 DateTime 中的秒值。Returns the seconds value in the specified DateTime.

(继承自 Calendar)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
GetWeekOfYear(DateTime, CalendarWeekRule, DayOfWeek)

返回一年中包含指定 DateTime 值中的日期的那个星期。Returns the week of the year that includes the date in the specified DateTime.

GetYear(DateTime)

返回指定 DateTime 中的年份。Returns the year in the specified DateTime.

IsLeapDay(Int32, Int32, Int32)

确定当前纪元中的指定日期是否为闰日。Determines whether the specified date in the current era is a leap day.

(继承自 Calendar)
IsLeapDay(Int32, Int32, Int32, Int32)

确定指定纪元中的指定日期是否为闰日。Determines whether the specified date in the specified era is a leap day.

IsLeapMonth(Int32, Int32)

确定当前纪元中指定年份的指定月份是否为闰月。Determines whether the specified month in the specified year in the current era is a leap month.

(继承自 Calendar)
IsLeapMonth(Int32, Int32, Int32)

确定指定纪元中指定年份的指定月份是否为闰月。Determines whether the specified month in the specified year in the specified era is a leap month.

IsLeapYear(Int32)

确定当前纪元中的指定年份是否为闰年。Determines whether the specified year in the current era is a leap year.

(继承自 Calendar)
IsLeapYear(Int32, Int32)

确定指定纪元中的指定年份是否为闰年。Determines whether the specified year in the specified era is a leap year.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32)

返回设置为当前纪元中指定日期和时间的 DateTimeReturns a DateTime that is set to the specified date and time in the current era.

(继承自 Calendar)
ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32)

返回设置为指定纪元中指定日期和时间的 DateTimeReturns a DateTime that is set to the specified date and time in the specified era.

ToFourDigitYear(Int32)

使用 TwoDigitYearMax 属性将指定的年份转换为四位数年份,以确定相应的纪元。Converts the specified year to a four-digit year by using the TwoDigitYearMax property to determine the appropriate century.

ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

适用于

另请参阅