HebrewCalendar Class

HebrewCalendar Class

 

Represents the Hebrew calendar.

Namespace:   System.Globalization
Assembly:  mscorlib (in mscorlib.dll)

System.Object
  System.Globalization.Calendar
    System.Globalization.HebrewCalendar

[SerializableAttribute]
[ComVisibleAttribute(true)]
public class HebrewCalendar : Calendar

NameDescription
System_CAPS_pubmethodHebrewCalendar()

Initializes a new instance of the HebrewCalendar class.

NameDescription
System_CAPS_pubpropertyAlgorithmType

Gets a value that indicates whether the current calendar is solar-based, lunar-based, or a combination of both.(Overrides Calendar.AlgorithmType.)

System_CAPS_protpropertyDaysInYearBeforeMinSupportedYear

Gets the number of days in the year that precedes the year that is specified by the MinSupportedDateTime property.(Inherited from Calendar.)

System_CAPS_pubpropertyEras

Gets the list of eras in the HebrewCalendar.(Overrides Calendar.Eras.)

System_CAPS_pubpropertyIsReadOnly

Gets a value indicating whether this Calendar object is read-only.(Inherited from Calendar.)

System_CAPS_pubpropertyMaxSupportedDateTime

Gets the latest date and time supported by the HebrewCalendar type.(Overrides Calendar.MaxSupportedDateTime.)

System_CAPS_pubpropertyMinSupportedDateTime

Gets the earliest date and time supported by the HebrewCalendar type.(Overrides Calendar.MinSupportedDateTime.)

System_CAPS_pubpropertyTwoDigitYearMax

Gets or sets the last year of a 100-year range that can be represented by a 2-digit year.(Overrides Calendar.TwoDigitYearMax.)

NameDescription
System_CAPS_pubmethodAddDays(DateTime, Int32)

Returns a DateTime that is the specified number of days away from the specified DateTime.(Inherited from Calendar.)

System_CAPS_pubmethodAddHours(DateTime, Int32)

Returns a DateTime that is the specified number of hours away from the specified DateTime.(Inherited from Calendar.)

System_CAPS_pubmethodAddMilliseconds(DateTime, Double)

Returns a DateTime that is the specified number of milliseconds away from the specified DateTime.(Inherited from Calendar.)

System_CAPS_pubmethodAddMinutes(DateTime, Int32)

Returns a DateTime that is the specified number of minutes away from the specified DateTime.(Inherited from Calendar.)

System_CAPS_pubmethodAddMonths(DateTime, Int32)

Returns a DateTime that is the specified number of months away from the specified DateTime.(Overrides Calendar.AddMonths(DateTime, Int32).)

System_CAPS_pubmethodAddSeconds(DateTime, Int32)

Returns a DateTime that is the specified number of seconds away from the specified DateTime.(Inherited from Calendar.)

System_CAPS_pubmethodAddWeeks(DateTime, Int32)

Returns a DateTime that is the specified number of weeks away from the specified DateTime.(Inherited from Calendar.)

System_CAPS_pubmethodAddYears(DateTime, Int32)

Returns a DateTime that is the specified number of years away from the specified DateTime.(Overrides Calendar.AddYears(DateTime, Int32).)

System_CAPS_pubmethodClone()

Creates a new object that is a copy of the current Calendar object.(Inherited from Calendar.)

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetDayOfMonth(DateTime)

Returns the day of the month in the specified DateTime.(Overrides Calendar.GetDayOfMonth(DateTime).)

System_CAPS_pubmethodGetDayOfWeek(DateTime)

Returns the day of the week in the specified DateTime.(Overrides Calendar.GetDayOfWeek(DateTime).)

System_CAPS_pubmethodGetDayOfYear(DateTime)

Returns the day of the year in the specified DateTime.(Overrides Calendar.GetDayOfYear(DateTime).)

System_CAPS_pubmethodGetDaysInMonth(Int32, Int32)

Returns the number of days in the specified month and year of the current era.(Inherited from Calendar.)

System_CAPS_pubmethodGetDaysInMonth(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).)

System_CAPS_pubmethodGetDaysInYear(Int32)

Returns the number of days in the specified year of the current era.(Inherited from Calendar.)

System_CAPS_pubmethodGetDaysInYear(Int32, Int32)

Returns the number of days in the specified year in the specified era.(Overrides Calendar.GetDaysInYear(Int32, Int32).)

System_CAPS_pubmethodGetEra(DateTime)

Returns the era in the specified DateTime.(Overrides Calendar.GetEra(DateTime).)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetHour(DateTime)

Returns the hours value in the specified DateTime.(Inherited from Calendar.)

System_CAPS_pubmethodGetLeapMonth(Int32)

Calculates the leap month for a specified year.(Inherited from Calendar.)

System_CAPS_pubmethodGetLeapMonth(Int32, Int32)

Calculates the leap month for a specified year and era.(Overrides Calendar.GetLeapMonth(Int32, Int32).)

System_CAPS_pubmethodGetMilliseconds(DateTime)

Returns the milliseconds value in the specified DateTime.(Inherited from Calendar.)

System_CAPS_pubmethodGetMinute(DateTime)

Returns the minutes value in the specified DateTime.(Inherited from Calendar.)

System_CAPS_pubmethodGetMonth(DateTime)

Returns the month in the specified DateTime.(Overrides Calendar.GetMonth(DateTime).)

System_CAPS_pubmethodGetMonthsInYear(Int32)

Returns the number of months in the specified year in the current era.(Inherited from Calendar.)

System_CAPS_pubmethodGetMonthsInYear(Int32, Int32)

Returns the number of months in the specified year in the specified era.(Overrides Calendar.GetMonthsInYear(Int32, Int32).)

System_CAPS_pubmethodGetSecond(DateTime)

Returns the seconds value in the specified DateTime.(Inherited from Calendar.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodGetWeekOfYear(DateTime, CalendarWeekRule, DayOfWeek)

Returns the week of the year that includes the date in the specified DateTime value.(Inherited from Calendar.)

System_CAPS_pubmethodGetYear(DateTime)

Returns the year in the specified DateTime value.(Overrides Calendar.GetYear(DateTime).)

System_CAPS_pubmethodIsLeapDay(Int32, Int32, Int32)

Determines whether the specified date in the current era is a leap day.(Inherited from Calendar.)

System_CAPS_pubmethodIsLeapDay(Int32, Int32, Int32, Int32)

Determines whether the specified date in the specified era is a leap day.(Overrides Calendar.IsLeapDay(Int32, Int32, Int32, Int32).)

System_CAPS_pubmethodIsLeapMonth(Int32, Int32)

Determines whether the specified month in the specified year in the current era is a leap month.(Inherited from Calendar.)

System_CAPS_pubmethodIsLeapMonth(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).)

System_CAPS_pubmethodIsLeapYear(Int32)

Determines whether the specified year in the current era is a leap year.(Inherited from Calendar.)

System_CAPS_pubmethodIsLeapYear(Int32, Int32)

Determines whether the specified year in the specified era is a leap year.(Overrides Calendar.IsLeapYear(Int32, Int32).)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToDateTime(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.)

System_CAPS_pubmethodToDateTime(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).)

System_CAPS_pubmethodToFourDigitYear(Int32)

Converts the specified year to a 4-digit year by using the TwoDigitYearMax property to determine the appropriate century.(Overrides Calendar.ToFourDigitYear(Int32).)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubfieldSystem_CAPS_staticHebrewEra

Represents the current era. This field is constant.

The Hebrew calendar recognizes two eras: B.C.E. (before the common era) and A.M. (Latin "Anno Mundi", which means "the year of the world"). This implementation of the HebrewCalendar class recognizes only the current era (A.M.) and the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar).

System_CAPS_noteNote

For information about using the HebrewCalendar class and the other calendar classes in the .NET Framework, see Working with Calendars.

In every 19-year cycle that ends with a year that is evenly divisible by 19, the 3rd, 6th, 8th, 11th, 14th, 17th, and 19th years are leap years. A common year can have from 353 to 355 days, depending on the placement of Jewish holidays. A leap year can have from 383 to 385 days.

The Hebrew calendar has 12 months during common years and 13 months during leap years:

GetMonth value (common year)

GetMonth value (leap year)

Month

Days in common years

Days in leap years

1

1

תשרי (Tishrei)

30

30

2

2

חשון (Cheshvan)

29/30

29/30

3

3

כסלו (Kislev)

29/30

29/30

4

4

טבת (Tevet)

29

29

5

5

שבט (Shevat)

30

30

6

-

אדר (Adar)

29

-

-

6

אדר א (Adar Alef)

-

30

-

7

אדר ב (Adar Beit)

-

29

7

8

ניסן (Nissan)

30

30

8

9

אייר (Iyar)

29

29

9

10

סיון (Sivan)

30

30

10

11

תמוז (Tamuz)

29

29

11

12

אב (Av)

30

30

12

13

אלול (Elul)

29

29

The days in Cheshvan and Kislev vary depending on the placement of Jewish holidays. During leap years, Adar is replaced by Adar Alef with 30 days and Adar Beit with 29 days. Adar Alef is considered the leap month. The last day of Adar Alef and all the days in Adar Beit are considered leap days; that is, the IsLeapDay method returns true for these days.

The date January 1, 2001 A.D. in the Gregorian calendar is equivalent to the sixth day of Tevet in the year 5761 A.M. in the Hebrew calendar.

Each CultureInfo 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.

The following example creates a file that contains the date ranges supported by the HebrewCalendar class, and displays the number of days in each month of the year 5772.

using System;
using System.Globalization;
using System.IO;
using System.Threading;

public class Example
{
   public static void Main()
   {
      StreamWriter output = new StreamWriter("HebrewCalendarInfo.txt");

      // Make the Hebrew Calendar the current calendar and
      // Hebrew (Israel) the current thread culture.
      HebrewCalendar hc = new HebrewCalendar();
      CultureInfo culture = CultureInfo.CreateSpecificCulture("he-IL");
      culture.DateTimeFormat.Calendar = hc;
      Thread.CurrentThread.CurrentCulture = culture;

      output.WriteLine("{0} Information:\n", 
                       GetCalendarName(culture.DateTimeFormat.Calendar));

      // Get the calendar range expressed in both Hebrew calendar and
      // Gregorian calendar dates.
      output.WriteLine("Start Date: {0} ", hc.MinSupportedDateTime);  
      culture.DateTimeFormat.Calendar = culture.Calendar;
      output.WriteLine("            ({0} Gregorian)\n", 
                       hc.MinSupportedDateTime);

      culture.DateTimeFormat.Calendar = hc;
      output.WriteLine("End Date: {0} ", hc.MaxSupportedDateTime);
      culture.DateTimeFormat.Calendar = culture.Calendar;
      output.WriteLine("          ({0} Gregorian)\n", 
                       hc.MaxSupportedDateTime);  

      culture.DateTimeFormat.Calendar = hc;

      // Get the year in the Hebrew calendar that corresponds to 1/1/2012
      // and display information about it.
      DateTime startOfYear = new DateTime(2012, 1, 1);
      output.WriteLine("Days in the Year {0}: {1}\n", 
                       hc.GetYear(startOfYear), 
                       hc.GetDaysInYear(hc.GetYear(startOfYear)));

      output.WriteLine("Days in Each Month of {0}:\n", hc.GetYear(startOfYear));
      output.WriteLine("Month       Days       Month Name");
      // Change start of year to first day of first month 
      startOfYear = hc.ToDateTime(hc.GetYear(startOfYear), 1, 1, 0, 0, 0, 0);
      DateTime startOfMonth = startOfYear;
      for (int ctr = 1; ctr <= hc.GetMonthsInYear(hc.GetYear(startOfYear)); ctr++) { 
         output.Write(" {0,2}", ctr);
         output.WriteLine("{0,12}{1,15:MMM}", 
                          hc.GetDaysInMonth(hc.GetYear(startOfMonth), hc.GetMonth(startOfMonth)),
                          startOfMonth);  
         startOfMonth = hc.AddMonths(startOfMonth, 1);                 
      } 

      output.Close();          
   }

   private static string GetCalendarName(Calendar cal) 
   {
      return cal.ToString().Replace("System.Globalization.", "").Replace("Cal", " Cal");
   }
}
// The example displays the following output:
//       Hebrew Calendar Information:
//       
//       Start Date: ז// טבת שמ"ג 00:00:00 
//                   (01/01/1583 00:00:00 Gregorian)
//       
//       End Date: כ"ט אלול תתקצ"ט 23:59:59 
//                 (29/09/2239 23:59:59 Gregorian)
//       
//       Days in the Year 5772: 354
//       
//       Days in Each Month of 5772:
//       
//       Month       Days       Month Name
//         1          30           תשרי
//         2          29           חשון
//         3          30           כסלו
//         4          29            טבת
//         5          30            שבט
//         6          29            אדר
//         7          30           ניסן
//         8          29           אייר
//         9          30           סיון
//        10          29           תמוז
//        11          30             אב
//        12          29           אלול

The example instantiates a HebrewCalendar object and makes it the current calendar of a Hebrew (Israel) CultureInfo object. It then makes Hebrew (Israel) the current thread culture. This causes the common language runtime to interpret all dates and times in relation to the Hebrew calendar.

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft