cancel
Showing results for 
Search instead for 
Did you mean: 

date which is after n number of days from a specified date

Former Member
0 Kudos

hello,

In Java, how do I get the date which is after n number of days from a specified date ?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,



	java.util.Date date = new java.util.Date();
	
	Calendar calD = Calendar.getInstance();	
	
	calD.setTime(date);
	
	calD.add(Calendar.DATE,10);
	
	date.setTime(calD.getTimeInMillis());

now this "date" holds the date which is after 10 daysfrom the current date.

pass your " n" in place of the 10 to get the desired date.

and set your desired date to calD.setTime();


Hope it helps you.

Regards,

ramesh

Former Member
0 Kudos

Hi,

Use

Calendar cal = Calendar.getInstance();

cal.add(Calendar.DAY_OF_MONTH, 5);

http://java.sun.com/j2se/1.5.0/docs/api/java/util/Calendar.html#add(int,%20int)

Regards

Ayyapparaj