Freigeben über


GregorianCalendar-Klasse

Stellt den gregorianischen Kalender dar.

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

Syntax

'Declaration
<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Class GregorianCalendar
    Inherits Calendar
'Usage
Dim instance As GregorianCalendar
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public class GregorianCalendar : Calendar
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public ref class GregorianCalendar : public Calendar
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public class GregorianCalendar extends Calendar
SerializableAttribute 
ComVisibleAttribute(true) 
public class GregorianCalendar extends Calendar

Hinweise

Der gregorianische Kalender umfasst zwei Zeiträume: v. Chr. (vor Christus) bzw. v. u. Z. (vor unserer Zeitrechnung) und n. Chr. (nach Christus) bzw. u. Z. (unserer Zeitrechnung). Die vorliegende Implementierung der GregorianCalendar-Klasse umfasst nur den Zeitraum nach Christi Geburt (n. Chr. bzw. u. Z.).

Ein Schaltjahr ist im gregorianischen Kalender als ein Jahr definiert, das ohne Rest durch 4 teilbar ist, sofern es nicht durch 100 teilbar ist. Bei Jahren, die durch 400 teilbar sind, handelt es sich jedoch ebenfalls um Schaltjahre. So war das Jahr 1900 im Gegensatz zum Jahr 2000 z. B. kein Schaltjahr. Ein Gemeinjahr hat 365 und ein Schaltjahr 366 Tage.

Der gregorianische Kalender besteht aus 12 Monaten mit je 28 bis 31 Tagen: Januar (31 Tage), Februar (28 oder 29 Tage), März (31 Tage), April (30 Tage), Mai (31 Tage), Juni (30 Tage), Juli (31 Tage), August (31 Tage), September (30 Tage), Oktober (31 Tage), November (30 Tage) und Dezember (31 Tage). Der Februar hat während eines Schaltjahres 29 und während eines Gemeinjahres 28 Tage.

Jede CultureInfo unterstützt eine Gruppe von Kalendern. Die Calendar-Eigenschaft gibt den Standardkalender für die Kultur an, und die OptionalCalendars-Eigenschaft gibt ein Array mit allen von der Kultur unterstützten Kalendern an. Um den von einer CultureInfo verwendeten Kalender zu ändern, legen Sie die Calendar-Eigenschaft von CultureInfo.DateTimeFormat auf einen neuen Calendar fest.

GetEra ignoriert die Interpunktion in abgekürzten Zeitraumnamen nur dann, wenn der GregorianCalendar in DateTimeFormatInfo.Calendar ausgewählt ist und die Kultur "A.D." als Namen des Zeitraums verwendet, d. h., "A.D." ist äquivalent zu "AD".

Beispiel

Im folgenden Codebeispiel wird veranschaulicht, dass DateTimeFormatInfo die Interpunktion im Namen des Zeitraums nur dann ignoriert, wenn es sich um den gregorianischen Kalender handelt und die Kultur den Zeitraumnamen "A.D." verwendet.

Imports System
Imports System.Globalization

Public Class SamplesGregorianCalendar

   Public Shared Sub Main()

      ' Creates strings with punctuation and without.
      Dim strADPunc As [String] = "A.D."
      Dim strADNoPunc As [String] = "AD"
      Dim strCEPunc As [String] = "C.E."
      Dim strCENoPunc As [String] = "CE"

      ' Calls DTFI.GetEra for each culture that uses GregorianCalendar as the default calendar.
      Console.WriteLine("            ----- AD -----  ----- CE -----")
      Console.WriteLine("CULTURE     PUNC   NO PUNC  PUNC   NO PUNC  CALENDAR")
      Dim myCI As CultureInfo
      For Each myCI In  CultureInfo.GetCultures(CultureTypes.SpecificCultures)
         Console.Write("{0,-12}", myCI)
         Console.Write("{0,-7}{1,-9}", myCI.DateTimeFormat.GetEra(strADPunc), myCI.DateTimeFormat.GetEra(strADNoPunc))
         Console.Write("{0,-7}{1,-9}", myCI.DateTimeFormat.GetEra(strCEPunc), myCI.DateTimeFormat.GetEra(strCENoPunc))
         Console.Write("{0}", myCI.Calendar)
         Console.WriteLine()
      Next myCI

   End Sub 'Main 

End Class 'SamplesGregorianCalendar


'This code produces the following output.  This output has been cropped for brevity.
'
'            ----- AD -----  ----- CE -----
'CULTURE     PUNC   NO PUNC  PUNC   NO PUNC  CALENDAR
'ar-SA       -1     -1       -1     -1       System.Globalization.HijriCalendar
'ar-IQ       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-EG       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-LY       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-DZ       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-MA       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-TN       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-OM       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-YE       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-SY       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-JO       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-LB       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-KW       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-AE       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-BH       1      1        -1     -1       System.Globalization.GregorianCalendar
'ar-QA       1      1        -1     -1       System.Globalization.GregorianCalendar
'bg-BG       1      1        -1     -1       System.Globalization.GregorianCalendar
'ca-ES       -1     -1       -1     -1       System.Globalization.GregorianCalendar
'zh-TW       -1     -1       -1     -1       System.Globalization.GregorianCalendar
'zh-CN       -1     -1       -1     -1       System.Globalization.GregorianCalendar
'zh-HK       -1     -1       -1     -1       System.Globalization.GregorianCalendar
'zh-SG       1      1        -1     -1       System.Globalization.GregorianCalendar
'zh-MO       1      1        -1     -1       System.Globalization.GregorianCalendar
'cs-CZ       -1     -1       -1     -1       System.Globalization.GregorianCalendar
'da-DK       1      1        -1     -1       System.Globalization.GregorianCalendar
using System;
using System.Globalization;


public class SamplesGregorianCalendar  {

   public static void Main()  {

      // Creates strings with punctuation and without.
      String strADPunc = "A.D.";
      String strADNoPunc = "AD";
      String strCEPunc = "C.E.";
      String strCENoPunc = "CE";

      // Calls DTFI.GetEra for each culture that uses GregorianCalendar as the default calendar.
      Console.WriteLine( "            ----- AD -----  ----- CE -----" );
      Console.WriteLine( "CULTURE     PUNC   NO PUNC  PUNC   NO PUNC  CALENDAR" );
      foreach ( CultureInfo myCI in CultureInfo.GetCultures( CultureTypes.SpecificCultures ) )  {
         Console.Write( "{0,-12}", myCI );
         Console.Write( "{0,-7}{1,-9}", myCI.DateTimeFormat.GetEra( strADPunc ), myCI.DateTimeFormat.GetEra( strADNoPunc ) );
         Console.Write( "{0,-7}{1,-9}", myCI.DateTimeFormat.GetEra( strCEPunc ), myCI.DateTimeFormat.GetEra( strCENoPunc ) );
         Console.Write( "{0}", myCI.Calendar );
         Console.WriteLine();
      }

   }

}

/*
This code produces the following output.  This output has been cropped for brevity.

            ----- AD -----  ----- CE -----
CULTURE     PUNC   NO PUNC  PUNC   NO PUNC  CALENDAR
ar-SA       -1     -1       -1     -1       System.Globalization.HijriCalendar
ar-IQ       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-EG       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-LY       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-DZ       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-MA       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-TN       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-OM       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-YE       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-SY       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-JO       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-LB       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-KW       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-AE       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-BH       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-QA       1      1        -1     -1       System.Globalization.GregorianCalendar
bg-BG       1      1        -1     -1       System.Globalization.GregorianCalendar
ca-ES       -1     -1       -1     -1       System.Globalization.GregorianCalendar
zh-TW       -1     -1       -1     -1       System.Globalization.GregorianCalendar
zh-CN       -1     -1       -1     -1       System.Globalization.GregorianCalendar
zh-HK       -1     -1       -1     -1       System.Globalization.GregorianCalendar
zh-SG       1      1        -1     -1       System.Globalization.GregorianCalendar
zh-MO       1      1        -1     -1       System.Globalization.GregorianCalendar
cs-CZ       -1     -1       -1     -1       System.Globalization.GregorianCalendar
da-DK       1      1        -1     -1       System.Globalization.GregorianCalendar

*/
using namespace System;
using namespace System::Globalization;
using namespace System::Collections;
int main()
{
   
   // Creates strings with punctuation and without.
   String^ strADPunc = "A.D.";
   String^ strADNoPunc = "AD";
   String^ strCEPunc = "C.E.";
   String^ strCENoPunc = "CE";
   
   // Calls DTFI::GetEra for each culture that uses GregorianCalendar as the default calendar.
   Console::WriteLine( "            ----- AD -----  ----- CE -----" );
   Console::WriteLine( "CULTURE     PUNC   NO PUNC  PUNC   NO PUNC  CALENDAR" );
   IEnumerator^ en = CultureInfo::GetCultures( CultureTypes::SpecificCultures )->GetEnumerator();
   while ( en->MoveNext() )
   {
      CultureInfo^ myCI = safe_cast<CultureInfo^>(en->Current);
      Console::Write( "{0, -12}", myCI );
      Console::Write( "{0,-7}{1,-9}", myCI->DateTimeFormat->GetEra( strADPunc ), myCI->DateTimeFormat->GetEra( strADNoPunc ) );
      Console::Write( "{0, -7}{1, -9}", myCI->DateTimeFormat->GetEra( strCEPunc ), myCI->DateTimeFormat->GetEra( strCENoPunc ) );
      Console::Write( "{0}", myCI->Calendar );
      Console::WriteLine();
   }
}

/*
This code produces the following output.  This output has been cropped for brevity.

            ----- AD -----  ----- CE -----
CULTURE     PUNC   NO PUNC  PUNC   NO PUNC  CALENDAR
ar-SA       -1     -1       -1     -1       System.Globalization.HijriCalendar
ar-IQ       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-EG       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-LY       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-DZ       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-MA       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-TN       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-OM       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-YE       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-SY       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-JO       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-LB       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-KW       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-AE       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-BH       1      1        -1     -1       System.Globalization.GregorianCalendar
ar-QA       1      1        -1     -1       System.Globalization.GregorianCalendar
bg-BG       1      1        -1     -1       System.Globalization.GregorianCalendar
ca-ES       -1     -1       -1     -1       System.Globalization.GregorianCalendar
zh-TW       -1     -1       -1     -1       System.Globalization.GregorianCalendar
zh-CN       -1     -1       -1     -1       System.Globalization.GregorianCalendar
zh-HK       1      1        -1     -1       System.Globalization.GregorianCalendar
zh-SG       1      1        -1     -1       System.Globalization.GregorianCalendar
zh-MO       1      1        -1     -1       System.Globalization.GregorianCalendar
cs-CZ       -1     -1       -1     -1       System.Globalization.GregorianCalendar
da-DK       1      1        -1     -1       System.Globalization.GregorianCalendar

*/
import System.* ;
import System.Globalization.* ;

public class SamplesGregorianCalendar
{
    public static void main(String[] args)
    {
        // Creates strings with punctuation and without.
        String strADPunc = "A.D.";
        String strADNoPunc = "AD";
        String strCEPunc = "C.E.";
        String strCENoPunc = "CE";

        // Calls DTFI.GetEra for each culture that uses GregorianCalendar as 
        //the default calendar.
        Console.WriteLine("            ----- AD -----  ----- CE -----");
        Console.WriteLine("CULTURE PUNC NO PUNC  PUNC   NO PUNC  CALENDAR");
        for (int iCtr = 0; iCtr < (CultureInfo.GetCultures(
            CultureTypes.SpecificCultures).length); iCtr++) {

            CultureInfo myCI = CultureInfo.GetCultures( 
                CultureTypes.SpecificCultures)[iCtr];
            Console.Write("{0,-12}", myCI);
            Console.Write("{0,-7}{1,-9}", System.Convert.ToString(
                myCI.get_DateTimeFormat().GetEra(strADPunc)),System.Convert.
                ToString(myCI.get_DateTimeFormat().GetEra(strADNoPunc)));
            
            Console.Write("{0,-7}{1,-9}", System.Convert.ToString(
                myCI.get_DateTimeFormat().GetEra(strCEPunc)), 
                System.Convert.ToString(myCI.get_DateTimeFormat().
                GetEra(strCENoPunc)));
            
            Console.Write("{0}", myCI.get_Calendar());
            Console.WriteLine();
        }
    } //main
} //SamplesGregorianCalendar

/*
This code produces the following output.  This output has been cropped 
for brevity.

            ----- AD -----  ----- CE -----
CULTURE     PUNC   NO PUNC  PUNC   NO PUNC  CALENDAR
ar-SA       -1     -1       -1     -1       System.Globalization.HijriCalendar
ar-IQ       1      1        -1     -1       System.Globalization.
                                            GregorianCalendar
ar-EG       1      1        -1     -1       System.Globalization.
                                            GregorianCalendar
ar-LY       1      1        -1     -1       System.Globalization.
                                            GregorianCalendar
ar-DZ       1      1        -1     -1       System.Globalization.
                                            GregorianCalendar
ar-MA       1      1        -1     -1       System.Globalization.
                                            GregorianCalendar
ar-TN       1      1        -1     -1       System.Globalization.
                                            GregorianCalendar
ar-OM       1      1        -1     -1       System.Globalization.
                                            GregorianCalendar
ar-YE       1      1        -1     -1       System.Globalization.
                                            GregorianCalendar
ar-SY       1      1        -1     -1       System.Globalization.
                                            GregorianCalendar
ar-JO       1      1        -1     -1       System.Globalization.
                                            GregorianCalendar
ar-LB       1      1        -1     -1       System.Globalization.
                                            GregorianCalendar
ar-KW       1      1        -1     -1       System.Globalization.
                                            GregorianCalendar
ar-AE       1      1        -1     -1       System.Globalization.
                                            GregorianCalendar
ar-BH       1      1        -1     -1       System.Globalization.
                                            GregorianCalendar
ar-QA       1      1        -1     -1       System.Globalization.
                                            GregorianCalendar
bg-BG       1      1        -1     -1       System.Globalization.
                                            GregorianCalendar
ca-ES       -1     -1       -1     -1       System.Globalization.
                                            GregorianCalendar
zh-TW       -1     -1       -1     -1       System.Globalization.
                                            GregorianCalendar
zh-CN       -1     -1       -1     -1       System.Globalization.
                                            GregorianCalendar
zh-HK       -1     -1       -1     -1       System.Globalization.
                                            GregorianCalendar
zh-SG       1      1        -1     -1       System.Globalization.
                                            GregorianCalendar
zh-MO       1      1        -1     -1       System.Globalization.
                                            GregorianCalendar
cs-CZ       -1     -1       -1     -1       System.Globalization.
                                            GregorianCalendar
da-DK       1      1        -1     -1       System.Globalization.
                                            GregorianCalendar
*/

Vererbungshierarchie

System.Object
   System.Globalization.Calendar
    System.Globalization.GregorianCalendar

Threadsicherheit

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

GregorianCalendar-Member
System.Globalization-Namespace
Calendar-Klasse
CultureInfo.Calendar-Eigenschaft
CultureInfo.OptionalCalendars-Eigenschaft