This is a common way but there is an important point that must be considered.
If your Date objects' timestamps are initialized, this method may give you wrong result.
Here is an example
startDate -- > 20 NOV 2003 02.00
endDate -- > 19 NOV 2003 23.59
then (startDate.getTime() - endDate.getTime)/(1000*60*60*24)
will give you 0 not 1.
If you are not going to set the time fields (then the time values will be 00:00:00) there is no problem but if your are setting the time values, then you have to think of a method that overcomes this sort problem.
Salih Sipahi
Software Engineer.
City of Istanbul Turkey
s.sipahi@sahinlerholding.com.tr
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.