Re: java.util.Date.getTime() returns odd results
807569Jul 19 2006 — edited Jul 20 2006Hi. I'm using the Java 1.5.0_07 environment, and I expect that the number of milliseconds for a whole day should be 86400000, which is the product of (1000 milliseconds/second*3600 seconds/hr*24 hrs/day), as given in <http://access1.sun.com/FAQSets/newtojavatechfaq.html>, question 17.
However, I'm seeing a different behavior when I attempt to perform operations over a date range which includes dates before and (on or after) April 4, 2005.
When I call the getTime() method on an instance of java.util.Date which is set to April 3, 2005, the value that is returned is 1112504400000 milliseconds. Likewise, when I do the same for a Date instance set to April 4, 2005, the value that is returned is 1112587200000 milliseconds. The difference between these two values is 82800000 milliseconds, which is not the same number of milliseconds that I expect for a whole day.
Besides this case, all date difference operations that I'm doing return values that are integer multiples of the # of milliseconds per day, 86400000.
Does anyone know whether the problem is user (ie my ;) error?
Thanks!
Raj