構文
public DtpDate addDays(int numberOfDays)
パラメーター
戻り値
新しい DtpDate オブジェクト。
例外
DtpDateException
注記
addDays() メソッドは、指定した日数をこの日付に加算します。get() メソッドを使用すると、結果の新しい日付に関する情報を検索できます。戻される DtpDate オブジェクトは、月名、日付形式など、DtpDate の現在のオブジェクトのプロパティーをすべて継承します。
新しい日付は、有効な日付に合わせて調整されます。例えば、1999 年 1 月 29 日 1999 00:00:00 に 5 日を加算すると、1999 年 2 月 03 日 00:00:00 になり、-30 日を加算すると、1998 年 12 月 30 日 00:00:00 になります。
日を加算しても、時刻には影響しません。
例
try { DtpDate toDay = new DtpDate(); DtpDate tomorrow = toDay.addDays(1); System.out.println("Tomorrow is " + tomorrow.getDayOfMonth() + "/" + tomorrow.getNumericMonth() + "/" + tomorrow.getYear() + " " + tomorrow.getHours() + ":" + tomorrow.getMinutes() + ":" + tomorrow.getSeconds()); } catch ( DtpDateException date_e ) { System.out.println(date_e.getMessage()); }
参照項目