Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Re: java.util.Date.getTime() returns odd results

807569Jul 19 2006 — edited Jul 20 2006
Hi. 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 17 2006
Added on Jul 19 2006
3 comments
219 views