File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes calculate duration between two dates Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "calculate duration between two dates" Watch "calculate duration between two dates" New topic
Author

calculate duration between two dates

tejeshwar sahu
Greenhorn

Joined: Mar 16, 2005
Posts: 1
please give me solution how to calculate duration between two dates. its very arrgent.
thanking you!
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Well, tradition way is to chnage them into milliseconds, using getTime() method of Date class, then after you got the difference back, change it back to Date...

But there is another tool available out there which you don't need such thing to do... You might want to have a look at their site...
http://joda-time.sourceforge.net

Even though there is a need to compensate for the learning curve, you won't regreat using that... I always use that, whenever I have to deal with Date-related stuff in my work, since I know how to use them... I got to know about that here in the Ranch as well...


Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Well, tradition way is to chnage them into milliseconds, using getTime() method of Date class, then after you got the difference back, change it back to Date...


Change it back to date ? But why ? The difference should be in terms of x days and not date right?
For e.g. What is the duration between today and saturday ? It will be 2 days and some hours , right.


Groovy
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Check this thread at the Sun forum
http://forum.java.sun.com/thread.jspa?threadID=581338&messageID=2951168
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calculate duration between two dates