Re: convert date from VB to java
- From: David McDivitt <x12code-del@xxxxxxxxxxxxx>
- Date: Fri, 16 Sep 2005 14:17:08 -0500
>From: "Jim Mack" <jmack@xxxxxxxxxxxxxxx>
>Date: Fri, 16 Sep 2005 15:00:38 -0400
>Lines: 30
>
>>=20
>> Have it all working now. I was distracted by the fact Microsoft uses
>> the date as the whole part of the double and the time as the
>> fractional part. The difference in days between Microsoft and java is
>> -25569. Java uses a 64 bit integer for date, with 86400000
>> milliseconds per day. All that's necessary is to subtract 25569 from
>> the double and multiply by 86400000.=20
>>=20
>> Java has a method Double.longBitsToDouble which will convert a 64 bit
>> integer to a java double, if the value contains the proper IEEE
>> structure.=20
>>=20
>> When I read the saved VB date, each byte is added, multiplying each
>> byte by 256 to the zero power, to the first power, second, etc., for
>> all eight bytes. That is passed to Double.longBitsToDouble to get a
>> double in java. When the double is used in the date formula above,
>> the java converted date is obtained.
>
>
>Sorry, that got away from me.
>
>So java uses 1-1-1970 as its base date, just like time_t (unix / C =
>standard), and counts msec from that base. Pretty standard stuff.
>
>I don't see the need for the other gyrations. Does java not use IEEE =
>floating point, like every other modern PC language? Why can't you just =
>read the value directly into a java double?
Java saves and stores in big-endian rather than little-endian. Also there
are no user defined types, or data structures, in java. There are objects
and all that, which are highly structured, but there is no data structure as
such.
Don't know if Java uses IEEE floating point or not. No matter. Can't read
in, anyway, because bytes are in reverse order. If the
Double.longBitsToDouble method was not present, bytes read would have to be
reduced all the way to bits, then the double constructed that way.
.
- References:
- convert date from VB to java
- From: David McDivitt
- Re: convert date from VB to java
- From: Jim Mack
- Re: convert date from VB to java
- From: David McDivitt
- Re: convert date from VB to java
- From: Jim Mack
- Re: convert date from VB to java
- From: Jim Mack
- convert date from VB to java
- Prev by Date: Re: Designer
- Next by Date: Re: user control width property
- Previous by thread: Re: convert date from VB to java
- Next by thread: Re: convert date from VB to java
- Index(es):
Relevant Pages
|