KoreanCalendar.GetDaysInMonth(Int32, Int32, Int32) メソッド

定義

指定した時代 (年号) の指定した年の指定した月の日数を返します。

public:
 override int GetDaysInMonth(int year, int month, int era);
public override int GetDaysInMonth (int year, int month, int era);
override this.GetDaysInMonth : int * int * int -> int
Public Overrides Function GetDaysInMonth (year As Integer, month As Integer, era As Integer) As Integer

パラメーター

year
Int32

年を表す整数。

month
Int32

月を表す 1 から 12 の整数。

era
Int32

時代 (年号) を表す整数。

戻り値

指定した時代 (年号) の指定した年の指定した月の日数。

例外

year が暦でサポートされている範囲外です。

- または -

month が暦でサポートされている範囲外です。

- または -

era が暦でサポートされている範囲外です。

次のコード例では、各時代 (年号) の 5 年間ごとに 2 か月目の GetDaysInMonth を呼び出します。

using namespace System;
using namespace System::Globalization;
int main()
{
   
   // Creates and initializes a KoreanCalendar.
   KoreanCalendar^ myCal = gcnew KoreanCalendar;
   
   // Displays the header.
   Console::Write( "YEAR\t" );
   for ( int y = 4334; y <= 4338; y++ )
      Console::Write( "\t {0}", y );
   Console::WriteLine();
   
   // Displays the value of the CurrentEra property.
   Console::Write( "CurrentEra:" );
   for ( int y = 4334; y <= 4338; y++ )
      Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, KoreanCalendar::CurrentEra ) );
   Console::WriteLine();
   
   // Displays the values in the Eras property.
   for ( int i = 0; i < myCal->Eras->Length; i++ )
   {
      Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
      for ( int y = 4334; y <= 4338; y++ )
         Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] ) );
      Console::WriteLine();

   }
}

/*
This code produces the following output.

YEAR            4334    4335    4336    4337    4338
CurrentEra:     28      28      28      29      28
Era 1:          28      28      28      29      28

*/
using System;
using System.Globalization;

public class SamplesKoreanCalendar  {

   public static void Main()  {

      // Creates and initializes a KoreanCalendar.
      KoreanCalendar myCal = new KoreanCalendar();

      // Displays the header.
      Console.Write( "YEAR\t" );
      for ( int y = 4334; y <= 4338; y++ )
         Console.Write( "\t{0}", y );
      Console.WriteLine();

      // Displays the value of the CurrentEra property.
      Console.Write( "CurrentEra:" );
      for ( int y = 4334; y <= 4338; y++ )
         Console.Write( "\t{0}", myCal.GetDaysInMonth( y, 2, KoreanCalendar.CurrentEra ) );
      Console.WriteLine();

      // Displays the values in the Eras property.
      for ( int i = 0; i < myCal.Eras.Length; i++ )  {
         Console.Write( "Era {0}:\t", myCal.Eras[i] );
         for ( int y = 4334; y <= 4338; y++ )
            Console.Write( "\t{0}", myCal.GetDaysInMonth( y, 2, myCal.Eras[i] ) );
         Console.WriteLine();
      }
   }
}

/*
This code produces the following output.

YEAR            4334    4335    4336    4337    4338
CurrentEra:     28      28      28      29      28
Era 1:          28      28      28      29      28

*/
Imports System.Globalization

Public Class SamplesKoreanCalendar   
   
   Public Shared Sub Main()

      ' Creates and initializes a KoreanCalendar.
      Dim myCal As New KoreanCalendar()

      ' Displays the header.
      Console.Write("YEAR" + ControlChars.Tab)
      Dim y As Integer
      For y = 4334 To 4338
         Console.Write(ControlChars.Tab + "{0}", y)
      Next y
      Console.WriteLine()

      ' Displays the value of the CurrentEra property.
      Console.Write("CurrentEra:")
      For y = 4334 To 4338
         Console.Write(ControlChars.Tab + "{0}", myCal.GetDaysInMonth(y, 2, KoreanCalendar.CurrentEra))
      Next y
      Console.WriteLine()

      ' Displays the values in the Eras property.
      Dim i As Integer
      For i = 0 To myCal.Eras.Length - 1
         Console.Write("Era {0}:" + ControlChars.Tab, myCal.Eras(i))
         For y = 4334 To 4338
            Console.Write(ControlChars.Tab + "{0}", myCal.GetDaysInMonth(y, 2, myCal.Eras(i)))
         Next y
         Console.WriteLine()
      Next i

   End Sub

End Class


'This code produces the following output.
'
'YEAR            4334    4335    4336    4337    4338
'CurrentEra:     28      28      28      29      28
'Era 1:          28      28      28      29      28

注釈

たとえば、このメソッドは閏年かどうかyearに応じて、2 月 (month = 2) の 28 または 29 を返します。

適用対象

こちらもご覧ください