addDays()

Add the specified number of days to this date.

Syntax

public DtpDate addDays(int numberOfDays) 
 

Parameters

numberOfDays
An integer number. If it is a negative number, the new date will be the date numberOfDays days before the current instance of DtpDate.

Return values

A new DtpDate object.

Exceptions

DtpDateException
 

Notes

The addDays() method adds the specified number of days to this date. You can use the get() methods to retrieve information about the resulting new date. The DtpDate object returned inherits all the properties of the current object of DtpDate, such as month names, date format, and so on.

The new date will be adjusted to be a valid date. For example, adding five days to January 29, 1999 00:00:00 results in February 03, 1999 00:00:00, and adding -30 days results in December 30, 1998 00:00:00.

Adding days does not affect the time of day.

Examples

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());
    }
 

See also

addWeekdays(), addYears()

Copyright IBM Corp. 2003