| Author |
java method to calculate due date
|
Anu Preethi
Greenhorn
Joined: Dec 09, 2008
Posts: 3
|
|
Hi, I have a method to calculate current date. Now Ihave an attribute private int dueDate, this should be 2 weeks from current date. How to calculate the due date. Can someone please help. Thank you.
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16690
|
|
Originally posted by twix mars: I have a method to calculate current date. Now Ihave an attribute private int dueDate, this should be 2 weeks from current date. How to calculate the due date.
You have a couple of options... (1) you can use the Calendar class to calculate the two weeks from the current date, or (2) you can just get the time in milliseconds from the date, add two weeks worth of milliseconds, and then create a new data object. Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Anu Preethi
Greenhorn
Joined: Dec 09, 2008
Posts: 3
|
|
|
how do you do that henry?
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
java.util.Calendar. Read it, try the methods you think you should use (hint: they are quite well named), then come back if you still have any questions.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Ken Liao
Greenhorn
Joined: Dec 15, 2008
Posts: 10
|
|
Originally posted by Henry Wong: You have a couple of options... (1) you can use the Calendar class to calculate the two weeks from the current date, or (2) you can just get the time in milliseconds from the date, add two weeks worth of milliseconds, and then create a new data object. Henry
I agree, and I recommend Calendar class because the code will be more readable.
|
A man takes responsibility for his actions, right or wrong - <<Battlestar Galactica>>
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
Originally posted by kendarkfire: I agree, and I recommend Calendar class because the code will be more readable.
That's a bold move - posting with an invalid name just directly under a name violation warning. Since you've already been warned officially by Campbell just today I won't report this officially again, but be warned - you really need to change your display name here.
|
 |
 |
|
|
subject: java method to calculate due date
|
|
|