|
-
October 7th, 1999, 06:49 AM
#1
How to calculate given date in calendar
Hi,
I am just starting to learn Java by myself and now really don't know how to solve my problem.
I have problem in how to calculate calendar. For example, for any given date and given the N date you can calculate the new date.
Please help.
Thanks very much
-
October 7th, 1999, 09:58 AM
#2
Re: How to calculate given date in calendar
one solution is :
// Adding 10 days with the current date.
Calendar cal = Calendar.getInstance();
cal.set( Calendar.DATE , cal.get( Calendar.DATE ) +10 );
Another solution with the Date class is :
// Calculate milliseconds for current date and add milliseconds for 10 days with it.
Date d = new Date();
long nSeconds = d.getTime() + ( 10 * 24 * 60 * 60 * 1000 );
d.setTime(nSeconds);
But i am getting weird result when i tried to add 30 days with the current date in Date
class. I dont have time to research on it.
Poochi..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|