Hello hi, I am new to this forum. Currently playing with the Date and Calendar classes. When I come across getting the milliseconds since Jan 1, 1970, I found there is indeed some difference by 20ms!!
The output: Current date/time: Sat Oct 06 00:30:22 GMT+08:00 2007 Cal Milliseconds since Thu Jan 01 08:00:00 GMT+08:00 1970: 1191601822049 Dt Milliseconds since Thu Jan 01 08:00:00 GMT+08:00 1970: 1191601822029
So my question is which method is more accurate - Calendar.getTimeInMillis() or Date.getTime()?
I have tried your little app and it seems more complicated than I had thought. What matters is which order the two lines which create the objects are in. Create the "cal" object before "dt" and "calMilli" is slightly less; create "dt" before "cal" and "dtMilli" is slightly less.
That should provide enough information for you to work out what the real problem is.
[EDIT]Minor spelling correction. And welcome to the Ranch [/EDIT] [ October 05, 2007: Message edited by: Campbell Ritchie ]