aspose file tools*
The moose likes Beginning Java and the fly likes java method to calculate due date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java method to calculate due date" Watch "java method to calculate due date" New topic
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: 18119
    
  39

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: 19543
    
  16

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 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Ken Liao
Greenhorn

Joined: Dec 15, 2008
Posts: 11
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: 19543
    
  16

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java method to calculate due date
 
Similar Threads
date manipulation
difference in days
Date calculation
Facing problems in subtracting two date.
sleep until a date occurs