Re: convert date from VB to java



>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.

.



Relevant Pages

  • Re: convert date from VB to java
    ... I was distracted by the fact Microsoft uses ... The difference in days between Microsoft and java is ... > 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 ...
    (microsoft.public.vb.general.discussion)
  • Re: convert date from VB to java
    ... I was distracted by the fact Microsoft uses ... The difference in days between Microsoft and java is ... > integer to a java double, if the value contains the proper IEEE ... > byte by 256 to the zero power, to the first power, second, etc., for ...
    (microsoft.public.vb.general.discussion)
  • Re: convert date from VB to java
    ... The VB program is mine and I am writing a java app to ... I was distracted by the fact Microsoft uses the ... > When I read the saved VB date, each byte is added, multiplying each byte ... > 256 to the zero power, to the first power, second, etc., for all eight ...
    (microsoft.public.vb.general.discussion)
  • Re: Critique of Robert C. Martins "Agile Principles, Patterns, and Practices"
    ... you can't claim C to be more high-level than Java. ... object, sometimes a set of tuples, sometimes a directed graph, ... hoops of creating other data structures from relations. ... it had to settle at the same time as those transactions. ...
    (comp.object)
  • Re: Road to Clojure Survey
    ... Java offers low level building material. ... That is used along with a STM and immutable data structures. ... Immutability is the default in Clojure. ...
    (comp.lang.lisp)