Freigeben über


GregorianCalendar-Konstruktor ()

Initialisiert eine neue Instanz der GregorianCalendar-Klasse, die den GregorianCalendarTypes-Standardwert verwendet.

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

Syntax

'Declaration
Public Sub New
'Usage
Dim instance As New GregorianCalendar
public GregorianCalendar ()
public:
GregorianCalendar ()
public GregorianCalendar ()
public function GregorianCalendar ()

Hinweise

Der GregorianCalendarTypes-Standardwert ist Localized. Wenn die DateTimeFormatInfo.Calendar-Eigenschaft der CultureInfo auf einen GregorianCalendar festgelegt ist, der mit diesem Konstruktor erstellt wurde, werden die Datums- und Uhrzeitangaben in der mit der CultureInfo verbundenen Sprache lokalisiert.

Beispiel

Im folgenden Codebeispiel wird eine DateTime unter Verwendung eines lokalisierten GregorianCalendar ausgegeben.

Imports System
Imports System.Globalization

Public Class SamplesGregorianCalendar

   Public Shared Sub Main()

      ' Creates and initializes three different CultureInfo.
      Dim myCIarSA As New CultureInfo("ar-SA", False)
      Dim myCIdeDE As New CultureInfo("de-DE", False)
      Dim myCIenUS As New CultureInfo("en-US", False)
      Dim myCIfrFR As New CultureInfo("fr-FR", False)

      ' Creates a Localized GregorianCalendar.
      ' GregorianCalendarTypes.Localized is the default when using the GregorianCalendar constructor without parameters.
      Dim myCal = New GregorianCalendar()

      ' Sets the DateTimeFormatInfo.Calendar property to a Localized GregorianCalendar.
      ' Localized GregorianCalendar is the default calendar for de-DE, en-US, and fr-FR,
      myCIarSA.DateTimeFormat.Calendar = myCal

      ' Creates a DateTime.
      Dim myDT As New DateTime(2002, 1, 3, 13, 30, 45)

      ' Displays the DateTime.
      Console.WriteLine("ar-SA: {0}", myDT.ToString("F", myCIarSA))
      Console.WriteLine("de-DE: {0}", myDT.ToString("F", myCIdeDE))
      Console.WriteLine("en-US: {0}", myDT.ToString("F", myCIenUS))
      Console.WriteLine("fr-FR: {0}", myDT.ToString("F", myCIfrFR))

   End Sub 'Main 

End Class 'SamplesGregorianCalendar


'This code produces the following output. The question marks take the place of native script characters.
'
'ar-SA: 03 ?????, 2002 01:30:45 ?
'de-DE: Donnerstag, 3. Januar 2002 13:30:45
'en-US: Thursday, January 03, 2002 1:30:45 PM
'fr-FR: jeudi 3 janvier 2002 13:30:45
using System;
using System.Globalization;


public class SamplesGregorianCalendar  {

   public static void Main()  {

      // Creates and initializes three different CultureInfo.
      CultureInfo myCIarSA = new CultureInfo("ar-SA", false);
      CultureInfo myCIdeDE = new CultureInfo("de-DE", false);
      CultureInfo myCIenUS = new CultureInfo("en-US", false);
      CultureInfo myCIfrFR = new CultureInfo("fr-FR", false);

      // Creates a Localized GregorianCalendar.
      // GregorianCalendarTypes.Localized is the default when using the GregorianCalendar constructor without parameters.
      Calendar myCal = new GregorianCalendar();

      // Sets the DateTimeFormatInfo.Calendar property to a Localized GregorianCalendar.
      // Localized GregorianCalendar is the default calendar for de-DE, en-US, and fr-FR,
      myCIarSA.DateTimeFormat.Calendar = myCal;

      // Creates a DateTime.
      DateTime myDT = new DateTime( 2002, 1, 3, 13, 30, 45 );

      // Displays the DateTime.
      Console.WriteLine( "ar-SA: {0}", myDT.ToString( "F", myCIarSA ) );
      Console.WriteLine( "de-DE: {0}", myDT.ToString( "F", myCIdeDE ) );
      Console.WriteLine( "en-US: {0}", myDT.ToString( "F", myCIenUS ) );
      Console.WriteLine( "fr-FR: {0}", myDT.ToString( "F", myCIfrFR ) );

   }

}

/*
This code produces the following output. The question marks take the place of native script characters.

ar-SA: 03 ?????, 2002 01:30:45 ?
de-DE: Donnerstag, 3. Januar 2002 13:30:45
en-US: Thursday, January 03, 2002 1:30:45 PM
fr-FR: jeudi 3 janvier 2002 13:30:45

*/
using namespace System;
using namespace System::Globalization;
int main()
{
   
   // Creates and initializes three different CultureInfo.
   CultureInfo^ myCIarSA = gcnew CultureInfo( "ar-SA",false );
   CultureInfo^ myCIdeDE = gcnew CultureInfo( "de-DE",false );
   CultureInfo^ myCIenUS = gcnew CultureInfo( "en-US",false );
   CultureInfo^ myCIfrFR = gcnew CultureInfo( "fr-FR",false );
   
   // Creates a Localized GregorianCalendar.
   // GregorianCalendarTypes::Localized is the default when using the GregorianCalendar constructor with->Item[Out] parameters.
   Calendar^ myCal = gcnew GregorianCalendar;
   
   // Sets the DateTimeFormatInfo::Calendar property to a Localized GregorianCalendar.
   // Localized GregorianCalendar is the default calendar for de-DE, en-US, and fr-FR,
   myCIarSA->DateTimeFormat->Calendar = myCal;
   
   // Creates a DateTime.
   DateTime myDT = DateTime(2002,1,3,13,30,45);
   
   // Displays the DateTime.
   Console::WriteLine( "ar-SA: {0}", myDT.ToString( "F", myCIarSA ) );
   Console::WriteLine( "de-DE: {0}", myDT.ToString( "F", myCIdeDE ) );
   Console::WriteLine( "en-US: {0}", myDT.ToString( "F", myCIenUS ) );
   Console::WriteLine( "fr-FR: {0}", myDT.ToString( "F", myCIfrFR ) );
}

/*
This code produces the following output. The question marks take the place of native script characters.

ar-SA: 03 ?????, 2002 01:30:45 ?
de-DE: Donnerstag, 3. Januar 2002 13:30:45
en-US: Thursday, January 03, 2002 1:30:45 PM
fr-FR: jeudi 3 janvier 2002 13:30:45

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

public class SamplesGregorianCalendar
{
    public static void main(String[] args)
    {
        // Creates and initializes three different CultureInfo.
        CultureInfo myCIarSA =  new CultureInfo("ar-SA", false);
        CultureInfo myCIdeDE =  new CultureInfo("de-DE", false);
        CultureInfo myCIenUS =  new CultureInfo("en-US", false);
        CultureInfo myCIfrFR =  new CultureInfo("fr-FR", false);

        // Creates a Localized GregorianCalendar.
        // GregorianCalendarTypes.Localized is the default when using the
        // GregorianCalendar constructor without parameters.
        Calendar myCal = new GregorianCalendar();

        // Sets the DateTimeFormatInfo.Calendar property to a 
        // Localized GregorianCalendar.
        // Localized GregorianCalendar is the default calendar for
        // de-DE, en-US, and fr-FR,
        myCIarSA.get_DateTimeFormat().set_Calendar( myCal);

        // Creates a DateTime.
        DateTime myDT =  new DateTime(2002, 1, 3, 13, 30, 45);

        // Displays the DateTime.
        Console.WriteLine("ar-SA: {0}", myDT.ToString("F", myCIarSA));
        Console.WriteLine("de-DE: {0}", myDT.ToString("F", myCIdeDE));
        Console.WriteLine("en-US: {0}", myDT.ToString("F", myCIenUS));
        Console.WriteLine("fr-FR: {0}", myDT.ToString("F", myCIfrFR));
    } //main 
} //SamplesGregorianCalendar

/*
This code produces the following output. The question marks take the place 
    of native script characters.

ar-SA: 03 ?????, 2002 01:30:45 ?
de-DE: Donnerstag, 3. Januar 2002 13:30:45
en-US: Thursday, January 03, 2002 1:30:45 PM
fr-FR: jeudi 3 janvier 2002 13:30:45
*/

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-Klasse
GregorianCalendar-Member
System.Globalization-Namespace
GregorianCalendarTypes