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 Date arithmetic Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Date arithmetic" Watch "Date arithmetic" New topic
Author

Date arithmetic

Simon Good
Ranch Hand

Joined: Sep 19, 2002
Posts: 30
Hi
How do I go about calculating the number of days between two dates? Is there a simple way to do it?
Thanks
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
Depends on what answer you want
how many days between monday and friday - 5?
how many days between 15th and 19th - 4?
actual days in-between 15th and 19th = 3
You can convert the dates to milliseconds, then subtract dt1 from dt2, then
convert the result back to days.
Here's a way where you can easily change the code, depending on the output
you want.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Date arithmetic
 
Similar Threads
Question on generic methods
Constructors
STRUTS: WHY???
junit classpath issue, I think
The x900 effect ?