Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java method to calculate due date

 
Anu Preethi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 21123
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Anu Preethi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do you do that henry?
 
Rob Spoor
Sheriff
Pie
Posts: 20531
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ken Liao
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rob Spoor
Sheriff
Pie
Posts: 20531
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic