JapaneseCalendar JapaneseCalendar JapaneseCalendar JapaneseCalendar Class

定義

代表日本曆法。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
繼承
JapaneseCalendarJapaneseCalendarJapaneseCalendarJapaneseCalendar
屬性

備註

日本曆 (也稱為 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使用類別和其他行事曆類別的相關資訊, 請參閱使用行事For information about using the JapaneseCalendar class and the other calendar classes in .NET, see Working with Calendars.

日文行事曆可辨識每個天皇的統治一個紀元。The Japanese calendar recognizes one era for every emperor's reign. 這兩個最新的紀元是 Heisei 紀元, 從西曆年1989開始, 而 Reiwa 紀元則從西曆年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", 結果字串中的輸出 Gannen, 而不是 "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 系統上測試您的應用程式,確保其已準備好面對紀元變更,請參閱 Prepare your application for the Japanese era change (讓應用程式準備好因應日本紀元變更)。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) 2019 5 月1日呈現May 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) 1926年12月25日至1989年1月7日December 25, 1926 to January 7, 1989
22 大正 (Taisho)大正 (Taisho) 大 (T, t)大 (T, t) 1912年7月30日至12月24日, 1926July 30, 1912 to December 24, 1926
11 明治 (Meiji)明治 (Meiji) 明 (M, m)明 (M, m) 1912年9月 1868 8 日至7月29日September 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) 1753January 3131 3131
22 2月 (Nigatsu)2月 (Nigatsu) 年2月February 2828 2929
33 3月 (Sangatsu)3月 (Sangatsu) 3 月March 3131 3131
44 4月 (Shigatsu)4月 (Shigatsu) WordApril 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) 年8月August 3131 3131
99 9月 (Kugatsu)9月 (Kugatsu) 年9月September 3030 3030
1010 10月 (Juugatsu)10月 (Juugatsu) October 3131 3131
1111 11月 (Juuichigatsu)11月 (Juuichigatsu) 2007November 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() JapaneseCalendar() JapaneseCalendar()

初始化 JapaneseCalendar 類別的新執行個體。Initializes a new instance of the JapaneseCalendar class.

屬性

AlgorithmType AlgorithmType AlgorithmType AlgorithmType

取得值,指出目前的月曆是以陽曆為主、以陰曆為主,還是同時包含兩種曆法。Gets a value that indicates whether the current calendar is solar-based, lunar-based, or a combination of both.

DaysInYearBeforeMinSupportedYear DaysInYearBeforeMinSupportedYear DaysInYearBeforeMinSupportedYear DaysInYearBeforeMinSupportedYear

取得 MinSupportedDateTime 屬性指定之年的前一年的天數。Gets the number of days in the year that precedes the year that is specified by the MinSupportedDateTime property.

(Inherited from Calendar)
Eras Eras Eras Eras

取得 JapaneseCalendar 中的紀元清單。Gets the list of eras in the JapaneseCalendar.

IsReadOnly IsReadOnly IsReadOnly IsReadOnly

取得值,指出 Calendar 物件是否為唯讀。Gets a value indicating whether this Calendar object is read-only.

(Inherited from Calendar)
MaxSupportedDateTime MaxSupportedDateTime MaxSupportedDateTime MaxSupportedDateTime

取得受目前 JapaneseCalendar 物件所支援的最晚日期和時間。Gets the latest date and time supported by the current JapaneseCalendar object.

MinSupportedDateTime MinSupportedDateTime MinSupportedDateTime MinSupportedDateTime

取得受目前 JapaneseCalendar 物件所支援的最早日期和時間。Gets the earliest date and time supported by the current JapaneseCalendar object.

TwoDigitYearMax TwoDigitYearMax TwoDigitYearMax 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) AddDays(DateTime, Int32) AddDays(DateTime, Int32) AddDays(DateTime, Int32)

傳回與指定 DateTime 相差指定日數的 DateTimeReturns a DateTime that is the specified number of days away from the specified DateTime.

(Inherited from Calendar)
AddHours(DateTime, Int32) AddHours(DateTime, Int32) AddHours(DateTime, Int32) AddHours(DateTime, Int32)

傳回與指定 DateTime 相差指定時數的 DateTimeReturns a DateTime that is the specified number of hours away from the specified DateTime.

(Inherited from Calendar)
AddMilliseconds(DateTime, Double) AddMilliseconds(DateTime, Double) AddMilliseconds(DateTime, Double) AddMilliseconds(DateTime, Double)

傳回與指定 DateTime 相差指定毫秒數的 DateTimeReturns a DateTime that is the specified number of milliseconds away from the specified DateTime.

(Inherited from Calendar)
AddMinutes(DateTime, Int32) AddMinutes(DateTime, Int32) AddMinutes(DateTime, Int32) AddMinutes(DateTime, Int32)

傳回與指定 DateTime 相差指定分鐘數的 DateTimeReturns a DateTime that is the specified number of minutes away from the specified DateTime.

(Inherited from Calendar)
AddMonths(DateTime, Int32) AddMonths(DateTime, Int32) AddMonths(DateTime, Int32) AddMonths(DateTime, Int32)

傳回與指定 DateTime 相差指定月數的 DateTimeReturns a DateTime that is the specified number of months away from the specified DateTime.

AddSeconds(DateTime, Int32) AddSeconds(DateTime, Int32) AddSeconds(DateTime, Int32) AddSeconds(DateTime, Int32)

傳回與指定 DateTime 相差指定秒數的 DateTimeReturns a DateTime that is the specified number of seconds away from the specified DateTime.

(Inherited from Calendar)
AddWeeks(DateTime, Int32) AddWeeks(DateTime, Int32) AddWeeks(DateTime, Int32) AddWeeks(DateTime, Int32)

傳回與指定 DateTime 相差指定週數的 DateTimeReturns a DateTime that is the specified number of weeks away from the specified DateTime.

(Inherited from Calendar)
AddYears(DateTime, Int32) AddYears(DateTime, Int32) AddYears(DateTime, Int32) AddYears(DateTime, Int32)

傳回與指定 DateTime 相差指定年數的 DateTimeReturns a DateTime that is the specified number of years away from the specified DateTime.

Clone() Clone() Clone() Clone()

建立目前 Calendar 物件複本的新物件。Creates a new object that is a copy of the current Calendar object.

(Inherited from Calendar)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetDayOfMonth(DateTime) GetDayOfMonth(DateTime) GetDayOfMonth(DateTime) GetDayOfMonth(DateTime)

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

GetDayOfWeek(DateTime) GetDayOfWeek(DateTime) GetDayOfWeek(DateTime) GetDayOfWeek(DateTime)

傳回指定 DateTime 中的星期。Returns the day of the week in the specified DateTime.

GetDayOfYear(DateTime) GetDayOfYear(DateTime) GetDayOfYear(DateTime) GetDayOfYear(DateTime)

傳回指定之 DateTime 中一年中的日期。Returns the day of the year in the specified DateTime.

GetDaysInMonth(Int32, Int32) GetDaysInMonth(Int32, Int32) GetDaysInMonth(Int32, Int32) GetDaysInMonth(Int32, Int32)

傳回目前紀元之指定月份和年份中的天數。Returns the number of days in the specified month and year of the current era.

(Inherited from Calendar)
GetDaysInMonth(Int32, Int32, Int32) GetDaysInMonth(Int32, Int32, Int32) GetDaysInMonth(Int32, Int32, Int32) GetDaysInMonth(Int32, Int32, Int32)

傳回在指定紀元的指定年份的指定月份中的日數。Returns the number of days in the specified month in the specified year in the specified era.

GetDaysInYear(Int32) GetDaysInYear(Int32) GetDaysInYear(Int32) GetDaysInYear(Int32)

傳回目前紀元之指定年份中的天數。Returns the number of days in the specified year of the current era.

(Inherited from Calendar)
GetDaysInYear(Int32, Int32) GetDaysInYear(Int32, Int32) GetDaysInYear(Int32, Int32) GetDaysInYear(Int32, Int32)

傳回在指定紀元的指定年份中的日數。Returns the number of days in the specified year in the specified era.

GetEra(DateTime) GetEra(DateTime) GetEra(DateTime) GetEra(DateTime)

傳回指定 DateTime 中的紀元。Returns the era in the specified DateTime.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetHour(DateTime) GetHour(DateTime) GetHour(DateTime) GetHour(DateTime)

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

(Inherited from Calendar)
GetLeapMonth(Int32) GetLeapMonth(Int32) GetLeapMonth(Int32) GetLeapMonth(Int32)

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

(Inherited from Calendar)
GetLeapMonth(Int32, Int32) GetLeapMonth(Int32, Int32) GetLeapMonth(Int32, Int32) GetLeapMonth(Int32, Int32)

計算指定年份和紀元的閏月。Calculates the leap month for a specified year and era.

GetMilliseconds(DateTime) GetMilliseconds(DateTime) GetMilliseconds(DateTime) GetMilliseconds(DateTime)

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

(Inherited from Calendar)
GetMinute(DateTime) GetMinute(DateTime) GetMinute(DateTime) GetMinute(DateTime)

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

(Inherited from Calendar)
GetMonth(DateTime) GetMonth(DateTime) GetMonth(DateTime) GetMonth(DateTime)

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

GetMonthsInYear(Int32) GetMonthsInYear(Int32) GetMonthsInYear(Int32) GetMonthsInYear(Int32)

傳回目前紀元的指定年份中的月數。Returns the number of months in the specified year in the current era.

(Inherited from Calendar)
GetMonthsInYear(Int32, Int32) GetMonthsInYear(Int32, Int32) GetMonthsInYear(Int32, Int32) GetMonthsInYear(Int32, Int32)

傳回在指定紀元的指定年份中的月數。Returns the number of months in the specified year in the specified era.

GetSecond(DateTime) GetSecond(DateTime) GetSecond(DateTime) GetSecond(DateTime)

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

(Inherited from Calendar)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
GetWeekOfYear(DateTime, CalendarWeekRule, DayOfWeek) GetWeekOfYear(DateTime, CalendarWeekRule, DayOfWeek) GetWeekOfYear(DateTime, CalendarWeekRule, DayOfWeek) GetWeekOfYear(DateTime, CalendarWeekRule, DayOfWeek)

傳回年份中的週,包含指定 DateTime 中的日期。Returns the week of the year that includes the date in the specified DateTime.

GetYear(DateTime) GetYear(DateTime) GetYear(DateTime) GetYear(DateTime)

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

IsLeapDay(Int32, Int32, Int32) IsLeapDay(Int32, Int32, Int32) IsLeapDay(Int32, Int32, Int32) IsLeapDay(Int32, Int32, Int32)

判斷目前紀元中指定日期是否為閏日。Determines whether the specified date in the current era is a leap day.

(Inherited from Calendar)
IsLeapDay(Int32, Int32, Int32, Int32) IsLeapDay(Int32, Int32, Int32, Int32) IsLeapDay(Int32, Int32, Int32, Int32) IsLeapDay(Int32, Int32, Int32, Int32)

判斷指定紀元中指定的日期是否為閏日。Determines whether the specified date in the specified era is a leap day.

IsLeapMonth(Int32, Int32) IsLeapMonth(Int32, Int32) IsLeapMonth(Int32, Int32) IsLeapMonth(Int32, Int32)

判斷目前紀元的指定年份中指定的月份是否為閏月。Determines whether the specified month in the specified year in the current era is a leap month.

(Inherited from Calendar)
IsLeapMonth(Int32, Int32, Int32) IsLeapMonth(Int32, Int32, Int32) IsLeapMonth(Int32, Int32, Int32) IsLeapMonth(Int32, Int32, Int32)

判斷指定紀元的指定年份中指定的月份是否為閏月。Determines whether the specified month in the specified year in the specified era is a leap month.

IsLeapYear(Int32) IsLeapYear(Int32) IsLeapYear(Int32) IsLeapYear(Int32)

判斷目前紀元中指定的年份是否為閏年。Determines whether the specified year in the current era is a leap year.

(Inherited from Calendar)
IsLeapYear(Int32, Int32) IsLeapYear(Int32, Int32) IsLeapYear(Int32, Int32) IsLeapYear(Int32, Int32)

判斷指定紀元中指定的年份是否為閏年。Determines whether the specified year in the specified era is a leap year.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32) ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32) ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32) ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32)

傳回設定為目前紀元中指定日期和時間的 DateTimeReturns a DateTime that is set to the specified date and time in the current era.

(Inherited from Calendar)
ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32) ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32) ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32) 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) ToFourDigitYear(Int32) ToFourDigitYear(Int32) ToFourDigitYear(Int32)

將指定的年份轉換為 4 位數年份,方法是使用 TwoDigitYearMax 屬性以判斷適當的世紀。Converts the specified year to a four-digit year by using the TwoDigitYearMax property to determine the appropriate century.

ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

欄位

CurrentEra CurrentEra CurrentEra CurrentEra

表示目前曆法的目前紀元。Represents the current era of the current calendar. 此欄位的值為 0。The value of this field is 0.

(Inherited from Calendar)

適用於

另請參閱