JapaneseCalendar.GetDaysInMonth(Int32, Int32, Int32) JapaneseCalendar.GetDaysInMonth(Int32, Int32, Int32) JapaneseCalendar.GetDaysInMonth(Int32, Int32, Int32) JapaneseCalendar.GetDaysInMonth(Int32, Int32, Int32) Method

定義

指定した時代 (年号) の指定した年の指定した月の日数を返します。Returns the number of days in the specified month in the specified year in the specified era.

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 Int32 Int32 Int32

年を表す整数。An integer that represents the year.

month
Int32 Int32 Int32 Int32

月を表す 1 から 12 の整数。An integer from 1 to 12 that represents the month.

era
Int32 Int32 Int32 Int32

時代 (年号) を表す整数。An integer that represents the era.

戻り値

指定した時代 (年号) の指定した年の指定した月の日数。The number of days in the specified month in the specified year in the specified era.

例外

year がカレンダーでサポートされている範囲外です。year is outside the range supported by the calendar.

または-or- month がカレンダーでサポートされている範囲外です。month is outside the range supported by the calendar.

または-or- era がカレンダーでサポートされている範囲外です。era is outside the range supported by the calendar.

次のコード例ではGetDaysInMonth各時代 (年号) の 5 年間のそれぞれに 2 番目の月。The following code example calls GetDaysInMonth for the second month in each of five years in each era.

using namespace System;
using namespace System::Globalization;
int main()
{
   
   // Creates and initializes a JapaneseCalendar.
   JapaneseCalendar^ myCal = gcnew JapaneseCalendar;
   
   // Displays the header.
   Console::Write( "YEAR\t" );
   for ( int y = 1; y <= 5; y++ )
      Console::Write( "\t {0}", y );
   Console::WriteLine();
   
   // Displays the value of the CurrentEra property.
   Console::Write( "CurrentEra:" );
   for ( int y = 1; y <= 5; y++ )
      Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, JapaneseCalendar::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 = 1; y <= 5; y++ )
         Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] ) );
      Console::WriteLine();

   }
}

/*
This code produces the following output.

YEAR            1       2       3       4       5
CurrentEra:     28      28      28      29      28
Era 4:          28      28      28      29      28
Era 3:          28      28      29      28      28
Era 2:          29      28      28      28      29
Era 1:          29      28      28      28      29

*/
using System;
using System.Globalization;


public class SamplesJapaneseCalendar  {

   public static void Main()  {

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

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

      // Displays the value of the CurrentEra property.
      Console.Write( "CurrentEra:" );
      for ( int y = 1; y <= 5; y++ )
         Console.Write( "\t{0}", myCal.GetDaysInMonth( y, 2, JapaneseCalendar.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 = 1; y <= 5; y++ )
            Console.Write( "\t{0}", myCal.GetDaysInMonth( y, 2, myCal.Eras[i] ) );
         Console.WriteLine();
      }

   }

}

/*
This code produces the following output.

YEAR            1       2       3       4       5
CurrentEra:     28      28      28      29      28
Era 4:          28      28      28      29      28
Era 3:          28      28      29      28      28
Era 2:          29      28      28      28      29
Era 1:          29      28      28      28      29

*/
Imports System
Imports System.Globalization
Imports Microsoft.VisualBasic

Public Class SamplesJapaneseCalendar   
   
   Public Shared Sub Main()

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

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

      ' Displays the value of the CurrentEra property.
      Console.Write("CurrentEra:")
      For y = 1 To 5
         Console.Write(ControlChars.Tab + "{0}", myCal.GetDaysInMonth(y, 2, JapaneseCalendar.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 = 1 To 5
            Console.Write(ControlChars.Tab + "{0}", myCal.GetDaysInMonth(y, 2, myCal.Eras(i)))
         Next y
         Console.WriteLine()
      Next i

   End Sub 'Main 

End Class 'SamplesJapaneseCalendar


'This code produces the following output.

'

'YEAR            1       2       3       4       5

'CurrentEra:     28      28      28      29      28

'Era 4:          28      28      28      29      28

'Era 3:          28      28      29      28      28

'Era 2:          29      28      28      28      29

'Era 1:          29      28      28      28      29


注釈

このメソッドが 28 または 29 を日数を返します、(2 月、 month = 2) かどうかに応じて、yearうるう年します。For example, this method returns 28 or 29 for Nigatsu (February, month = 2), depending on whether year is a leap year.

適用対象

こちらもご覧ください