Microsoft SDK for Java

Time.addDays

Creates a new Time object that represents the number of days after the time that this Time object represents.

Syntax

public Time addDays( double interval )

public Time addDays( int interval )

Parameters

interval

An integer or double value that represent the number of days to add to the current time.

Return Value

Returns a Time object that represents the new time.

Remarks

Time objects cannot be altered. Use the addDays method to create a new Time object whose date is based on the current Time object but incremented by the number of days specified in interval.

The following example illustrates how to use the addDays method to create a new Time object that is two days later in time than a Time object that is initialized to the current date:

public void AddTwoDays()
{
   //Create object that is set to current date
   Time now = new Time();
   //Output the current date
   System.out.println("The current date is: " + now.formatShortDate());
   
   //Increment the current time by two days
   Time twoDaysLater = now.addDays(2);
   //Output the date
   System.out.println("The date two days from now is: " + twoDaysLater.formatShortDate());
}

See Also   formatShortDate, addMonths, addYears

© 1999 Microsoft Corporation. All rights reserved. Terms of use.