aspose file tools
The moose likes Other JSE/JEE APIs and the fly likes Calculating Days Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Reply Bookmark "Calculating Days" Watch "Calculating Days" New topic
Author

Calculating Days

francis varkey
Ranch Hand

Joined: Sep 13, 2005
Posts: 155
Respected Sirs,

What is the best way for calculating number of days between two dates(java.util.Date object) ?

Thanks
Francis
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

Use java.util.Calendar:


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
francis varkey
Ranch Hand

Joined: Sep 13, 2005
Posts: 155
Wrong code:
please provide inputs "04/06/2008" and "05/09/2008".
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

Which produces 93, just like Visual Basic's DateDiff function does.
Well, that, is, using dd/MM/yyyy as the format. Otherwise it's 33, just like Visual Basic's DateDiff function does
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Calculating Days
 
Similar Threads
Date and Time manipulation
program calculating the mode
Date arithmetic
Invoking abstract method
caculating the difference between dates