Calendar 클래스

정의

사업부의 시간(예: 주, 월, 년)을 나타냅니다.

public ref class Calendar abstract
public ref class Calendar abstract : ICloneable
public abstract class Calendar
public abstract class Calendar : ICloneable
[System.Serializable]
public abstract class Calendar
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class Calendar : ICloneable
type Calendar = class
type Calendar = class
    interface ICloneable
[<System.Serializable>]
type Calendar = class
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type Calendar = class
    interface ICloneable
Public MustInherit Class Calendar
Public MustInherit Class Calendar
Implements ICloneable
상속
Calendar
파생
특성
구현

예제

다음 코드 예제에서는 클래스의 멤버를 보여 줍니다 Calendar .

using namespace System;
using namespace System::Globalization;
void DisplayValues( Calendar^ myCal, DateTime myDT )
{
   Console::WriteLine( "   Era: {0}", myCal->GetEra( myDT ) );
   Console::WriteLine( "   Year: {0}", myCal->GetYear( myDT ) );
   Console::WriteLine( "   Month: {0}", myCal->GetMonth( myDT ) );
   Console::WriteLine( "   DayOfYear: {0}", myCal->GetDayOfYear( myDT ) );
   Console::WriteLine( "   DayOfMonth: {0}", myCal->GetDayOfMonth( myDT ) );
   Console::WriteLine( "   DayOfWeek: {0}", myCal->GetDayOfWeek( myDT ) );
   Console::WriteLine( "   Hour: {0}", myCal->GetHour( myDT ) );
   Console::WriteLine( "   Minute: {0}", myCal->GetMinute( myDT ) );
   Console::WriteLine( "   Second: {0}", myCal->GetSecond( myDT ) );
   Console::WriteLine( "   Milliseconds: {0}", myCal->GetMilliseconds( myDT ) );
   Console::WriteLine();
}

int main()
{
   
   // Sets a DateTime to April 3, 2002 of the Gregorian calendar.
   DateTime myDT = DateTime(2002,4,3,gcnew GregorianCalendar);
   
   // Uses the default calendar of the InvariantCulture.
   Calendar^ myCal = CultureInfo::InvariantCulture->Calendar;
   
   // Displays the values of the DateTime.
   Console::WriteLine( "April 3, 2002 of the Gregorian calendar:" );
   DisplayValues( myCal, myDT );
   
   // Adds 5 to every component of the DateTime.
   myDT = myCal->AddYears( myDT, 5 );
   myDT = myCal->AddMonths( myDT, 5 );
   myDT = myCal->AddWeeks( myDT, 5 );
   myDT = myCal->AddDays( myDT, 5 );
   myDT = myCal->AddHours( myDT, 5 );
   myDT = myCal->AddMinutes( myDT, 5 );
   myDT = myCal->AddSeconds( myDT, 5 );
   myDT = myCal->AddMilliseconds( myDT, 5 );
   
   // Displays the values of the DateTime.
   Console::WriteLine( "After adding 5 to each component of the DateTime:" );
   DisplayValues( myCal, myDT );
}

/*
This code produces the following output.

April 3, 2002 of the Gregorian calendar:
Era:          1
Year:         2002
Month:        4
DayOfYear:    93
DayOfMonth:   3
DayOfWeek:    Wednesday
Hour:         0
Minute:       0
Second:       0
Milliseconds: 0

After adding 5 to each component of the DateTime:
Era:          1
Year:         2007
Month:        10
DayOfYear:    286
DayOfMonth:   13
DayOfWeek:    Saturday
Hour:         5
Minute:       5
Second:       5
Milliseconds: 5

*/
using System;
using System.Globalization;

public class SamplesCalendar  {

   public static void Main()  {

      // Sets a DateTime to April 3, 2002 of the Gregorian calendar.
      DateTime myDT = new DateTime( 2002, 4, 3, new GregorianCalendar() );

      // Uses the default calendar of the InvariantCulture.
      Calendar myCal = CultureInfo.InvariantCulture.Calendar;

      // Displays the values of the DateTime.
      Console.WriteLine( "April 3, 2002 of the Gregorian calendar:" );
      DisplayValues( myCal, myDT );

      // Adds 5 to every component of the DateTime.
      myDT = myCal.AddYears( myDT, 5 );
      myDT = myCal.AddMonths( myDT, 5 );
      myDT = myCal.AddWeeks( myDT, 5 );
      myDT = myCal.AddDays( myDT, 5 );
      myDT = myCal.AddHours( myDT, 5 );
      myDT = myCal.AddMinutes( myDT, 5 );
      myDT = myCal.AddSeconds( myDT, 5 );
      myDT = myCal.AddMilliseconds( myDT, 5 );

      // Displays the values of the DateTime.
      Console.WriteLine( "After adding 5 to each component of the DateTime:" );
      DisplayValues( myCal, myDT );
   }

   public static void DisplayValues( Calendar myCal, DateTime myDT )  {
      Console.WriteLine( "   Era:          {0}", myCal.GetEra( myDT ) );
      Console.WriteLine( "   Year:         {0}", myCal.GetYear( myDT ) );
      Console.WriteLine( "   Month:        {0}", myCal.GetMonth( myDT ) );
      Console.WriteLine( "   DayOfYear:    {0}", myCal.GetDayOfYear( myDT ) );
      Console.WriteLine( "   DayOfMonth:   {0}", myCal.GetDayOfMonth( myDT ) );
      Console.WriteLine( "   DayOfWeek:    {0}", myCal.GetDayOfWeek( myDT ) );
      Console.WriteLine( "   Hour:         {0}", myCal.GetHour( myDT ) );
      Console.WriteLine( "   Minute:       {0}", myCal.GetMinute( myDT ) );
      Console.WriteLine( "   Second:       {0}", myCal.GetSecond( myDT ) );
      Console.WriteLine( "   Milliseconds: {0}", myCal.GetMilliseconds( myDT ) );
      Console.WriteLine();
   }
}


/*
This code produces the following output.

April 3, 2002 of the Gregorian calendar:
   Era:          1
   Year:         2002
   Month:        4
   DayOfYear:    93
   DayOfMonth:   3
   DayOfWeek:    Wednesday
   Hour:         0
   Minute:       0
   Second:       0
   Milliseconds: 0

After adding 5 to each component of the DateTime:
   Era:          1
   Year:         2007
   Month:        10
   DayOfYear:    286
   DayOfMonth:   13
   DayOfWeek:    Saturday
   Hour:         5
   Minute:       5
   Second:       5
   Milliseconds: 5

*/
Imports System.Globalization


Public Class SamplesCalendar   

   Public Shared Sub Main()

      ' Sets a DateTime to April 3, 2002 of the Gregorian calendar.
      Dim myDT As New DateTime(2002, 4, 3, New GregorianCalendar())

      ' Uses the default calendar of the InvariantCulture.
      Dim myCal As Calendar = CultureInfo.InvariantCulture.Calendar

      ' Displays the values of the DateTime.
      Console.WriteLine("April 3, 2002 of the Gregorian calendar:")
      DisplayValues(myCal, myDT)

      ' Adds 5 to every component of the DateTime.
      myDT = myCal.AddYears(myDT, 5)
      myDT = myCal.AddMonths(myDT, 5)
      myDT = myCal.AddWeeks(myDT, 5)
      myDT = myCal.AddDays(myDT, 5)
      myDT = myCal.AddHours(myDT, 5)
      myDT = myCal.AddMinutes(myDT, 5)
      myDT = myCal.AddSeconds(myDT, 5)
      myDT = myCal.AddMilliseconds(myDT, 5)

      ' Displays the values of the DateTime.
      Console.WriteLine("After adding 5 to each component of the DateTime:")
      DisplayValues(myCal, myDT)

   End Sub

   Public Shared Sub DisplayValues(myCal As Calendar, myDT As DateTime)
      Console.WriteLine("   Era:          {0}", myCal.GetEra(myDT))
      Console.WriteLine("   Year:         {0}", myCal.GetYear(myDT))
      Console.WriteLine("   Month:        {0}", myCal.GetMonth(myDT))
      Console.WriteLine("   DayOfYear:    {0}", myCal.GetDayOfYear(myDT))
      Console.WriteLine("   DayOfMonth:   {0}", myCal.GetDayOfMonth(myDT))
      Console.WriteLine("   DayOfWeek:    {0}", myCal.GetDayOfWeek(myDT))
      Console.WriteLine("   Hour:         {0}", myCal.GetHour(myDT))
      Console.WriteLine("   Minute:       {0}", myCal.GetMinute(myDT))
      Console.WriteLine("   Second:       {0}", myCal.GetSecond(myDT))
      Console.WriteLine("   Milliseconds: {0}", myCal.GetMilliseconds(myDT))
      Console.WriteLine()
   End Sub

End Class


'This code produces the following output.
'
'April 3, 2002 of the Gregorian calendar:
'   Era:          1
'   Year:         2002
'   Month:        4
'   DayOfYear:    93
'   DayOfMonth:   3
'   DayOfWeek:    Wednesday
'   Hour:         0
'   Minute:       0
'   Second:       0
'   Milliseconds: 0
'
'After adding 5 to each component of the DateTime:
'   Era:          1
'   Year:         2007
'   Month:        10
'   DayOfYear:    286
'   DayOfMonth:   13
'   DayOfWeek:    Saturday
'   Hour:         5
'   Minute:       5
'   Second:       5
'   Milliseconds: 5

설명

달력은 시간을 주, 월 및 연도와 같은 단위로 나눕니다. 나누기의 수, 길이 및 시작은 각 달력에 따라 다릅니다.

참고

.NET에서 일정 클래스를 사용하는 방법에 대한 자세한 내용은 일정 작업을 참조하세요.

특정 달력을 사용하여 임의의 시간 단위를 숫자 값 집합으로 나타낼 수 있습니다. 예를 들어, 1999년 3월 20일 8:46:00:0.0에 그레고리오력의 (1999, 3, 20, 8, 46, 0, 0.0)에서 춘분이 발생했습니다. 의 Calendar 구현은 특정 달력 범위의 모든 날짜를 유사한 숫자 값 집합에 매핑할 수 있으며 DateTime 및 의 정보를 CalendarDateTimeFormatInfo사용하여 이러한 숫자 값 집합을 텍스트 표현에 매핑할 수 있습니다. 텍스트 표현은 예를 들어 en-US 문화권의 경우 "1999년 3월 20일 오전 8시 46분 AD"이거나, 예를 들어 ISO 8601 형식의 "1999-03-20T08:46:00"과 같이 문화권을 구분할 수 있습니다.

구현은 Calendar 하나 이상의 연대를 정의할 수 있습니다. 클래스는 Calendar 연대를 열거된 정수로 식별합니다. 여기서 현재 era(CurrentEra)의 값은 0입니다.

중요

일본어 달력의 시대는 천황 통치 기간을 기준으로 하므로 변경되어야 합니다. 예를 들어 2019년 5월 1일은 JapaneseCalendarJapaneseLunisolarCalendar에서 레이와 시대의 시작을 나타냅니다. 이러한 시대 변경 내용은 해당 달력을 사용하는 모든 애플리케이션에 영향을 줍니다. 자세한 내용과 애플리케이션이 영향을 받는지 여부를 확인하려면 .NET에서 일본 달력의 새 시대 처리를 참조하세요. Windows 시스템에서 애플리케이션을 테스트하여 시대 변화에 대한 준비 상태를 확인하는 방법에 대한 자세한 내용은 일본 시대 변화에 맞게 애플리케이션 준비를 참조하세요. 여러 시대가 있는 달력을 지원하는 .NET의 기능과 여러 연대를 지원하는 달력으로 작업할 때 모범 사례는 연대 작업을 참조하세요.

달력 연도와 지구가 태양 주위를 회전하는 실제 시간 또는 달이 지구 주위를 회전하는 실제 시간의 차이를 만회하기 위해 윤년은 표준 달력 연도와 다른 일 수를 줍니다. 각 Calendar 구현은 윤년을 다르게 정의합니다.

일관성을 위해 각 간격의 첫 번째 단위(예: 첫 번째 달)에 값 1이 할당됩니다.

네임스페이 System.Globalization 스에는 다음 Calendar 구현이 포함됩니다.

생성자

Calendar()

Calendar 클래스의 새 인스턴스를 초기화합니다.

필드

CurrentEra

현재 달력의 현재 연대를 나타냅니다. 이 필드의 값은 0입니다.

속성

AlgorithmType

현재 달력이 양력인지, 음력인지 또는 두 가지를 조합한 것인지를 나타내는 값을 가져옵니다.

DaysInYearBeforeMinSupportedYear

MinSupportedDateTime 속성에서 지정한 연도 이전 연도의 일 수를 가져옵니다.

Eras

파생 클래스에 재정의될 때 현재 달력의 연대 목록을 가져옵니다.

IsReadOnly

Calendar 개체가 읽기 전용인지 여부를 나타내는 값을 가져옵니다.

MaxSupportedDateTime

Calendar 개체에서 지원하는 마지막 날짜와 시간을 가져옵니다.

MinSupportedDateTime

Calendar 개체에서 지원하는 시작 날짜와 시간을 가져옵니다.

TwoDigitYearMax

두 자릿수 연도로 표시할 수 있는 100년 범위의 마지막 연도를 가져오거나 설정합니다.

메서드

AddDays(DateTime, Int32)

지정된 DateTime에서 지정된 날짜 수만큼 경과한 DateTime을 반환합니다.

AddHours(DateTime, Int32)

지정된 DateTime에서 지정된 시간 수만큼 경과한 DateTime을 반환합니다.

AddMilliseconds(DateTime, Double)

지정된 DateTime에서 지정된 밀리초 수만큼 경과한 DateTime을 반환합니다.

AddMinutes(DateTime, Int32)

지정된 DateTime에서 지정된 분 수만큼 경과한 DateTime을 반환합니다.

AddMonths(DateTime, Int32)

파생 클래스에 재정의될 때 지정된 DateTime에서 지정된 월 수만큼 경과한 DateTime을 반환합니다.

AddSeconds(DateTime, Int32)

지정된 DateTime에서 지정된 초 수만큼 경과한 DateTime을 반환합니다.

AddWeeks(DateTime, Int32)

지정된 DateTime에서 지정된 주 수만큼 경과한 DateTime을 반환합니다.

AddYears(DateTime, Int32)

파생 클래스에 재정의될 때 지정된 DateTime에서 지정된 연도 수만큼 경과한 DateTime을 반환합니다.

Clone()

현재 Calendar 개체의 복사본인 새 개체를 만듭니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetDayOfMonth(DateTime)

파생 클래스에 재정의될 때 지정된 DateTime의 날짜(월 기준)를 반환합니다.

GetDayOfWeek(DateTime)

파생 클래스에 재정의될 때 지정된 DateTime의 요일을 반환합니다.

GetDayOfYear(DateTime)

파생 클래스에 재정의될 때 지정된 DateTime의 날짜(연도 기준)를 반환합니다.

GetDaysInMonth(Int32, Int32)

현재 연대의 지정된 연도 및 월에 있는 일 수를 반환합니다.

GetDaysInMonth(Int32, Int32, Int32)

파생 클래스에 재정의될 때 지정된 월, 연도 및 연대의 일 수를 반환합니다.

GetDaysInYear(Int32)

현재 연대의 지정된 연도에 있는 일 수를 반환합니다.

GetDaysInYear(Int32, Int32)

파생 클래스에 재정의될 때 지정된 연도 및 연대의 일 수를 반환합니다.

GetEra(DateTime)

파생 클래스에 재정의될 때 지정된 DateTime의 연대를 반환합니다.

GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetHour(DateTime)

지정된 DateTime의 시간 값을 반환합니다.

GetLeapMonth(Int32)

지정된 연도의 윤월을 계산합니다.

GetLeapMonth(Int32, Int32)

지정한 연도 및 연대의 윤월을 계산합니다.

GetMilliseconds(DateTime)

지정된 DateTime의 밀리초 값을 반환합니다.

GetMinute(DateTime)

지정된 DateTime의 분 값을 반환합니다.

GetMonth(DateTime)

파생 클래스에 재정의될 때 지정된 DateTime의 월을 반환합니다.

GetMonthsInYear(Int32)

현재 연대에 있는 지정된 연도의 월 수를 반환합니다.

GetMonthsInYear(Int32, Int32)

파생 클래스에 재정의될 때 지정된 연대에 있는 지정된 연도의 월 수를 반환합니다.

GetSecond(DateTime)

지정된 DateTime의 초 값을 반환합니다.

GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
GetWeekOfYear(DateTime, CalendarWeekRule, DayOfWeek)

지정된 DateTime 값의 날짜가 포함된 주(연도 기준)를 반환합니다.

GetYear(DateTime)

파생 클래스에 재정의될 때 지정된 DateTime의 연도를 반환합니다.

IsLeapDay(Int32, Int32, Int32)

현재 연대의 지정된 날짜가 윤일인지 여부를 확인합니다.

IsLeapDay(Int32, Int32, Int32, Int32)

파생 클래스에 재정의될 때 지정된 연대의 지정된 날짜가 윤일인지 여부를 확인합니다.

IsLeapMonth(Int32, Int32)

현재 연대의 지정된 연도에 있는 지정된 월이 윤월인지 여부를 확인합니다.

IsLeapMonth(Int32, Int32, Int32)

파생 클래스에 재정의될 때 지정된 연대의 지정된 연도에 있는 지정된 월이 윤월인지 여부를 확인합니다.

IsLeapYear(Int32)

지정된 연대의 지정된 연도가 윤년인지 여부를 확인합니다.

IsLeapYear(Int32, Int32)

파생 클래스에 재정의될 때 지정된 연대의 지정된 연도가 윤년인지 여부를 확인합니다.

MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ReadOnly(Calendar)

지정된 Calendar 개체의 읽기 전용 버전을 반환합니다.

ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32)

현재 연대의 지정된 날짜와 시간으로 설정된 DateTime을 반환합니다.

ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32)

파생 클래스에 재정의될 때 지정된 연대의 지정된 날짜와 시간으로 설정된 DateTime을 반환합니다.

ToFourDigitYear(Int32)

TwoDigitYearMax 속성으로 해당 세기를 확인하여 지정된 연도를 네 자릿수 연도로 변환합니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보