File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Comparing dates Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Comparing dates" Watch "Comparing dates" New topic
Author

Comparing dates

Scott Appleton
Ranch Hand

Joined: May 07, 2001
Posts: 195
This feels like a dumb question, but browsing the API hasn't produced an answer for me yet.
I want to get an integer value for the number of days elapsed since a given date. I can create a new Date() object for today, but I can't find a method that will perform a date-date subtraction cleanly. I could use the DAY_OF_YEAR field, but that gets dirty once you start comparing dates from different years. There must be a cleaner way to do this.
Marcel de Jong
Ranch Hand

Joined: May 27, 2002
Posts: 54
Scott,
take a look at this link, it shows an example of how to calculate the number of days between two dates.compute days between 2 dates
Marcel
Snigdha Solanki
Ranch Hand

Joined: Sep 07, 2000
Posts: 128
I don't think API provides any straigt forward way to do this. You need to write your own logic to get the difference.


Snigdha<br />Sun Certified Programmer for the Java™ 2 Platform
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Comparing dates
 
Similar Threads
comparison of dates
Need a calendar picker and validation for From Date and To Date
comparing dates
problem with date validation
Calendar variables