Date Calculations - Difference between 2 dates is off

Hi, I have been looking for code examples of how to take 2 dates, compare them to see if the difference is > or < than a desired value, then perform an action. Here is the code I am using so far:

In my main app, I am executing the following:

The problem is, for comparing the time between 01.01.2002 and 06.30.2002, the result is 179 instead of 181. For 07.01.2002 to 12.31.2002, the result is 183 instead of 184. Where am I losing the accuracy here? I tried converting them to floats in order to make sure that rounding wasn't affecting this, but no luck. Can someone tell me the best practice for doing this? I would think this is a fairly common action that must be performed in programs. Thanks in advance! bp

Thanks for the responses. Just replace the method name with the one I originally posted about - getMilliDate() Also, I tried the diff method and it is still off by a day on the July-Dec 180 day measurement. Should return 184 and returns 183. Not sure what else to try. bp

if(date.compareTo(currentDate) = true) { send notification } ... [\CODE] The problem is that the date format that my query is returning is based on Novel eDir8.6.2/NDS. For example, 20021010152748Z. I would love to create a SimpleDateFormat for this and then just blow right on through. Is this a date format that many are familiar with? Thanks again! bp

I think that it doesn't need to take into account leap years, since it is only measuring units of time in days ( which day isn't important ). The number represents a measurement of one day. You might be seeing some discrepancies due to the precision of hours, minutes, seconds and so forth being used in the calculation, when you only want the precision to be days. If you make the dates using Calendars and set the hours, minutes, seconds and milliseconds to 0, you might solve the problem. If you want us to look at the details, post the code that is producing the faulty results ( especially the date creation part ). Jamie