Time.addSeconds

Overview | Methods | Fields | This Package | All Packages

Time.addSeconds

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

Syntax

public Time addSeconds( long interval )

Parameters

interval

A long value that represents the number of seconds to add to the current time.

Return Value

Returns a Time object representing the new time.

Remarks

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

Example

The following example illustrates how to use the addSeconds method to create a new Time object that is 30 seconds later in time than a Time object that is initialized to the current time:

public void AddThirtySeconds()
{
	//Create object that is set to current time
	Time now = new Time();
	//Output the current time
	System.out.println("The current time is: " + now.toString());
	
	//Increment the current time by 30 seconds
	Time thirtySeconds = now.addSeconds(30);
	//Output the time
	System.out.println("The time 30 seconds from now is: " + thirtySeconds.formatLongTime());
}

See Also   addMillis, addHours, addMinutes, formatLongTime