This topic has not yet been rated - Rate this topic

JapaneseCalendar Class

Updated: January 2012

Represents the Japanese calendar.

System.Object
  System.Globalization.Calendar
    System.Globalization.JapaneseCalendar

Namespace:  System.Globalization
Assembly:  mscorlib (in mscorlib.dll)
[SerializableAttribute]
[ComVisibleAttribute(true)]
public class JapaneseCalendar : Calendar

The JapaneseCalendar type exposes the following members.

  Name Description
Public method Supported by the XNA Framework JapaneseCalendar Initializes a new instance of the JapaneseCalendar class.
Top
  Name Description
Public property AlgorithmType Gets a value that indicates whether the current calendar is solar-based, lunar-based, or a combination of both. (Overrides Calendar.AlgorithmType.)
Public property Supported by the XNA Framework Eras Gets the list of eras in the JapaneseCalendar. (Overrides Calendar.Eras.)
Public property Supported by the XNA Framework IsReadOnly Gets a value indicating whether this Calendar object is read-only. (Inherited from Calendar.)
Public property Supported by the XNA Framework MaxSupportedDateTime Gets the latest date and time supported by the current JapaneseCalendar object. (Overrides Calendar.MaxSupportedDateTime.)
Public property Supported by the XNA Framework MinSupportedDateTime Gets the earliest date and time supported by the current JapaneseCalendar object. (Overrides Calendar.MinSupportedDateTime.)
Public property Supported by the XNA Framework TwoDigitYearMax Gets or sets the last year of a 100-year range that can be represented by a 2-digit year. (Overrides Calendar.TwoDigitYearMax.)
Top
  Name Description
Public method Supported by the XNA Framework AddDays Returns a DateTime that is the specified number of days away from the specified DateTime. (Inherited from Calendar.)
Public method Supported by the XNA Framework AddHours Returns a DateTime that is the specified number of hours away from the specified DateTime. (Inherited from Calendar.)
Public method Supported by the XNA Framework AddMilliseconds Returns a DateTime that is the specified number of milliseconds away from the specified DateTime. (Inherited from Calendar.)
Public method Supported by the XNA Framework AddMinutes Returns a DateTime that is the specified number of minutes away from the specified DateTime. (Inherited from Calendar.)
Public method Supported by the XNA Framework AddMonths Returns a DateTime that is the specified number of months away from the specified DateTime. (Overrides Calendar.AddMonths(DateTime, Int32).)
Public method Supported by the XNA Framework AddSeconds Returns a DateTime that is the specified number of seconds away from the specified DateTime. (Inherited from Calendar.)
Public method Supported by the XNA Framework AddWeeks Returns a DateTime that is the specified number of weeks away from the specified DateTime. (Inherited from Calendar.)
Public method Supported by the XNA Framework AddYears Returns a DateTime that is the specified number of years away from the specified DateTime. (Overrides Calendar.AddYears(DateTime, Int32).)
Public method Clone Creates a new object that is a copy of the current Calendar object. (Inherited from Calendar.)
Public method Supported by the XNA Framework Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Supported by the XNA Framework Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method Supported by the XNA Framework GetDayOfMonth Returns the day of the month in the specified DateTime. (Overrides Calendar.GetDayOfMonth(DateTime).)
Public method Supported by the XNA Framework GetDayOfWeek Returns the day of the week in the specified DateTime. (Overrides Calendar.GetDayOfWeek(DateTime).)
Public method Supported by the XNA Framework GetDayOfYear Returns the day of the year in the specified DateTime. (Overrides Calendar.GetDayOfYear(DateTime).)
Public method Supported by the XNA Framework GetDaysInMonth(Int32, Int32) Returns the number of days in the specified month and year of the current era. (Inherited from Calendar.)
Public method Supported by the XNA Framework GetDaysInMonth(Int32, Int32, Int32) Returns the number of days in the specified month in the specified year in the specified era. (Overrides Calendar.GetDaysInMonth(Int32, Int32, Int32).)
Public method Supported by the XNA Framework GetDaysInYear(Int32) Returns the number of days in the specified year of the current era. (Inherited from Calendar.)
Public method Supported by the XNA Framework GetDaysInYear(Int32, Int32) Returns the number of days in the specified year in the specified era. (Overrides Calendar.GetDaysInYear(Int32, Int32).)
Public method Supported by the XNA Framework GetEra Returns the era in the specified DateTime. (Overrides Calendar.GetEra(DateTime).)
Public method Supported by the XNA Framework GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method Supported by the XNA Framework GetHour Returns the hours value in the specified DateTime. (Inherited from Calendar.)
Public method GetLeapMonth(Int32) Calculates the leap month for a specified year. (Inherited from Calendar.)
Public method GetLeapMonth(Int32, Int32) Calculates the leap month for a specified year and era. (Overrides Calendar.GetLeapMonth(Int32, Int32).)
Public method Supported by the XNA Framework GetMilliseconds Returns the milliseconds value in the specified DateTime. (Inherited from Calendar.)
Public method Supported by the XNA Framework GetMinute Returns the minutes value in the specified DateTime. (Inherited from Calendar.)
Public method Supported by the XNA Framework GetMonth Returns the month in the specified DateTime. (Overrides Calendar.GetMonth(DateTime).)
Public method Supported by the XNA Framework GetMonthsInYear(Int32) Returns the number of months in the specified year in the current era. (Inherited from Calendar.)
Public method Supported by the XNA Framework GetMonthsInYear(Int32, Int32) Returns the number of months in the specified year in the specified era. (Overrides Calendar.GetMonthsInYear(Int32, Int32).)
Public method Supported by the XNA Framework GetSecond Returns the seconds value in the specified DateTime. (Inherited from Calendar.)
Public method Supported by the XNA Framework GetType Gets the Type of the current instance. (Inherited from Object.)
Public method Supported by the XNA Framework GetWeekOfYear Returns the week of the year that includes the date in the specified DateTime. (Overrides Calendar.GetWeekOfYear(DateTime, CalendarWeekRule, DayOfWeek).)
Public method Supported by the XNA Framework GetYear Returns the year in the specified DateTime. (Overrides Calendar.GetYear(DateTime).)
Public method Supported by the XNA Framework IsLeapDay(Int32, Int32, Int32) Determines whether the specified date in the current era is a leap day. (Inherited from Calendar.)
Public method Supported by the XNA Framework IsLeapDay(Int32, Int32, Int32, Int32) Determines whether the specified date in the specified era is a leap day. (Overrides Calendar.IsLeapDay(Int32, Int32, Int32, Int32).)
Public method Supported by the XNA Framework IsLeapMonth(Int32, Int32) Determines whether the specified month in the specified year in the current era is a leap month. (Inherited from Calendar.)
Public method Supported by the XNA Framework IsLeapMonth(Int32, Int32, Int32) Determines whether the specified month in the specified year in the specified era is a leap month. (Overrides Calendar.IsLeapMonth(Int32, Int32, Int32).)
Public method Supported by the XNA Framework IsLeapYear(Int32) Determines whether the specified year in the current era is a leap year. (Inherited from Calendar.)
Public method Supported by the XNA Framework IsLeapYear(Int32, Int32) Determines whether the specified year in the specified era is a leap year. (Overrides Calendar.IsLeapYear(Int32, Int32).)
Protected method Supported by the XNA Framework MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method Supported by the XNA Framework ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32) Returns a DateTime that is set to the specified date and time in the current era. (Inherited from Calendar.)
Public method Supported by the XNA Framework ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32) Returns a DateTime that is set to the specified date and time in the specified era. (Overrides Calendar.ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32).)
Public method Supported by the XNA Framework ToFourDigitYear Converts the specified year to a four-digit year by using the TwoDigitYearMax property to determine the appropriate century. (Overrides Calendar.ToFourDigitYear(Int32).)
Public method Supported by the XNA Framework ToString Returns a string that represents the current object. (Inherited from Object.)
Top

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.

The Japanese calendar recognizes one era for every emperor's reign. The current era is the Heisei era, which began in the Gregorian calendar year 1989. The era name is typically displayed before the year. For example, the Gregorian calendar year 2001 is the Japanese calendar year Heisei 13. Note that the first year of an era is called "Gannen." Therefore, the Gregorian calendar year 1989 was the Japanese calendar year Heisei Gannen.

This class assigns numbers to the eras as follows:

GetEra value

Era Name

Era Abbreviation

Gregorian Dates

4

平成 (Heisei)

平 (H, h)

January 8, 1989 to present

3

昭和 (Showa)

昭 (S, s)

December 25, 1926 to January 7, 1989

2

大正 (Taisho)

大 (T, t)

July 30, 1912 to December 24, 1926

1

明治 (Meiji)

明 (M, m)

September 8, 1868 to July 29, 1912

This class handles dates from September 8 in the year Meiji 1 (in the Gregorian calendar, September 8, 1868). 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. 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. However, Gregorian years that are divisible by 400 are leap years. A common year has 365 days and a leap year has 366 days.

The Japanese calendar has 12 months with 28 to 31 days each:

GetMonth value

Month

English

Days in common years

Days in leap years

1

1月 (Ichigatsu)

January

31

31

2

2月 (Nigatsu)

February

28

29

3

3月 (Sangatsu)

March

31

31

4

4月 (Shigatsu)

April

30

30

5

5月 (Gogatsu)

May

31

31

6

6月 (Rokugatsu)

June

30

30

7

7月 (Shichigatsu)

July

31

31

8

8月 (Hachigatsu)

August

31

31

9

9月 (Kugatsu)

September

30

30

10

10月 (Juugatsu)

October

31

31

11

11月 (Juuichigatsu)

November

30

30

12

12月 (Juunigatsu)

December

31

31

Nigatsu, which is equivalent to the Gregorian calendar month of February, has 29 days during leap years and 28 during common years.

The date January 1, 2001 A.D. in the Gregorian calendar is equivalent to the first day of Ichigatsu in the year Heisei 13 in the Japanese calendar.

If the application is using the JapaneseCalendar class, 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.

Each CultureInfo object supports a set of calendars. The Calendar property returns the default calendar for the culture, and the OptionalCalendars property returns an array containing all the calendars supported by the culture. To change the calendar used by a CultureInfo, the application should set the Calendar property of CultureInfo.DateTimeFormat to a new Calendar.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Date

History

Reason

January 2012

Corrected information about the Meiji era.

Customer feedback.

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Meiji did not start at Jan 1st. but October 23rd of 1868

Meiji did not start at Jan 1st, but started at Oct. 23rd of 1868.  
If you try to use Jan 1st of Meiji "gannen", you will get exception. Please fix.

JapaneseCalendar Class, MinSupportedDateTime, and Exceptions

Thanks for pointing this out. The documentation is incorrect on a number of points. First, the earliest date supported by the JapaneseCalendar class
(as reflected in its JapaneseCalendar.MinSupportedDateTime property) is September 8, 1868 in the Gregorian calendar (September 8 in the year Meiji 1 in the Japanese calendar). (I have no idea of why September 8 was chosen as the starting date of the Meiji era.) Second, some methods, notably the JapaneseCalendar.GetEra method, allow the DateTime parameter to be equal to any date in the first year of the era, including dates that are ordinarily out of range (that is, from January 1, 1868 through September 7, 1868). Third, in the JapaneseCalendar.GetEra method, we've documented an ArgumentException that is thrown if the date parameter is outside the supported range. The more specific exception that is thrown is an ArgumentOutOfRangeExceptionArgumentOutOfRangeException is derived from ArgumentException.

We've modified the documentation for the JapaneseCalendar class, the JapaneseCalendar.MinSupportedDateTime property, and the JapaneseCalendar.GetEra method to address these issues. The updated versions of the documentation should appear online in the near future.

Again, thanks for pointing out these inaccuracies.

--Ron Petrusha
Common Language Runtime User Education
Microsoft Corporation