Re: is the date example correct?

From: Scott Ferguson <ferg@xxx.com>
Date: Thu Apr 06 2006 - 08:36:01 PDT

On Apr 3, 2006, at 12:11 PM, Philippe Marschall wrote:

> Hi
>
> I already wrote this mail once but noone responded. Maybe it got lost
> or the people who know about it were in holidays. Now that Scott is
> back I repost it. Sorry, but I really want to know that.

The date should be milliseconds since the epoch in GMT. In other
words, it should be exactly the same as the Java date times. I'll
need to double check the example.

-- Scott

>
> I have a problem with the date example. I computed it three different
> languages and they all give the same result that is different than the
> spec. All these languages tell me 2:51:31 May 8, 1998 is 894595891000
> miliseconds since the epoch whereas the spec says it's 894621091000.
>
> Here's my Java Code
>
> int[] specData = {0x00, 0x00, 0x00, 0xd0, 0x4b, 0x92,
> 0x84, 0xb8};
> long expected = 0;
> for (int i = 0; i < 8; ++i) {
> expected <<= 8;
> expected |= specData[i];
> }
>
> Calendar calendar = Calendar.getInstance();
> TimeZone utc = TimeZone.getTimeZone("UTC");
> calendar.setTimeZone(utc);
> calendar.set(YEAR, 1998);
> calendar.set(MONTH, MAY);
> calendar.set(DAY_OF_MONTH, 8);
> calendar.set(HOUR_OF_DAY, 2);
> calendar.set(MINUTE, 51);
> calendar.set(SECOND, 31);
> calendar.set(MILLISECOND, 0);
>
> System.out.printf("my result:%tQ\n", calendar.getTime
> ());
> System.out.printf("spec: %d\n", expected);
>
> System.out.println("difference in milliseconds: " +
> (expected - calendar.getTimeInMillis())); //25200000
> System.out.println("difference in hours : " +
> (expected - calendar.getTimeInMillis()) / 1000 / 3600); //7
>
> long acutal = calendar.getTimeInMillis();
> int[] realData = new int[8];
> for (int i = 0; i < 8; ++i) {
> realData[i] = (int) acutal & 0xFF;
> acutal >>= 8;
> }
> System.out.printf("0x%02x 0x%02x 0x%02x 0x%02x 0x%02x
> 0x%02x 0x%02x 0x%02x", realData[7], realData[6], realData[5],
> realData[4], realData[3], realData[2], realData[1], realData[0]);
>
> Could you please tell me whether I or the spec is wrong (of both us).
>
> The spec doesn't mention it but I don't suspect that leapseconds
> are counted.
>
> And finally when playing around with the BasicAPI test I found out
> that remotes can't be serialized (I sent a remote to echo and got a
> fault as answer telling me it can't be serialized). Is there a special
> reason that this is not allowed or is this just a limitation of the
> Java implementation?
>
> Cheers
> Philippe
>
Received on Thu 06 Apr 2006 08:36:01 -0700

This archive was generated by hypermail 2.1.8 : Thu Sep 28 2006 - 20:16:41 PDT