Time.addMinutes

Overview | Methods | Fields | This Package | All Packages

Time.addMinutes

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

Syntax

public Time addMinutes( long interval )

Parameters

interval

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

Return Value

Returns a Time object representing the new time.

Remarks

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

Example

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

public void AddThirtyMinutes()
{
	//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 minutes
	Time thirtyMinutes = now.addMinutes(30);
	//Output the time
	System.out.println("The time 30 minutes from now is: " + thirtyMinutes.formatShortTime());
}

See Also   addMillis, addHours, addSeconds, formatShortTime