EastAsianLunisolarCalendar.AddMonths(DateTime, Int32) メソッド

定義

指定した日付から指定した月数が経過した後の日付を計算します。

public:
 override DateTime AddMonths(DateTime time, int months);
public override DateTime AddMonths (DateTime time, int months);
override this.AddMonths : DateTime * int -> DateTime
Public Overrides Function AddMonths (time As DateTime, months As Integer) As DateTime

パラメーター

time
DateTime

months を加算する対象の DateTime

months
Int32

加算する月の数。

戻り値

time パラメーターに指定した月数を加算した結果の、新しい DateTime

例外

結果が DateTime のサポート範囲外です。

months が -120000 より小さいか、または 120000 を超えています。

または

timeMinSupportedDateTime より小さいか MaxSupportedDateTime より大きいです。

注釈

結果の日が、結果 DateTime の年の結果の月の有効な日でない場合、結果の日の部分が影響を受ける。 この場合、日の部分は、結果として得られる年の結果の月の最後の有効な日に変更されます。 結果の月が指定DateTimeした の年以外の場合、結果DateTimeの年部分が影響を受ける。 この実装では、現在の時代 (年号) のみがサポートされます。 したがって、 は、 ArgumentException 結果として得られる年が、指定した の時代 (年号) を外れた場合にスローされます DateTime。 結果 DateTime の時刻部分は、指定した DateTimeと同じままです。

たとえば、指定した月が 31 日の 10 月の場合、指定した日はその月の 31 日で、パラメーターの値が 6 の場合、結果の months 年は指定した年より 1 つ多く、結果の月は 4 月、結果の日は 4 月の最終日である 30 日になります。

パラメーターの値が負の months 場合、結果 DateTime は指定した DateTimeよりも前になります。

返されるDateTime値の プロパティはKind常に とDateTimeKind.Unspecified等しくなります。 次の例に Kind 示すように、 メソッドを time 呼び出 DateTime.SpecifyKind すことで、 パラメーターの プロパティを保持できます。

returnTime = DateTime.SpecifyKind(cal.AddMonths(time, months), time.Kind);
returnTime = DateTime.SpecifyKind(cal.AddMonths(time, months), time.Kind)

適用対象