on 12-15-2008 2:08 PM
hello,
In Java, how do I get the date which is after n number of days from a specified date ?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.