realbasic-nug
[Top] [All Lists]

Java date to RB date

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Java date to RB date
From: Steve Roy <sroy at mac dot com>
Date: Sun, 31 Oct 2004 19:45:56 -0500
Delivered-to: realbasic-nug at lists dot realsoftware dot com
Hm, here's a fun one. I'm parsing a text file created by another program written in Java. The date is written as the number of milliseconds since January 1, 1970, 0:00:00, as the java.util.Date class defines it. When I convert this into a REALbasic date, the result doesn't match. Here's what I do:

dim millis as String = ... // Parsed text for the Java date
dte = new Date()
dte.Day = 1
dte.Month = 1
dte.Year = 1970
dte.Hour = 0
dte.Minute = 0
dte.Second = 0
dte.TotalSeconds = dte.TotalSeconds + Val(millis) / 1000

When displayed in my RB app, this thusly built date shows up as
        10/25/04 12:49 AM
whereas it shows up as
        10/24/04 8:49:26 PM
in the original Java app, which means I'm 17 hours off.

I'm trying to see what could account for this difference. Do you see something I missed? I thought that by creating a new date object and making it correspond to the reference Java date (1/1/1970 0:00:00), that everything would be peachy but it's not. Is there any other way I could do this?

Steve

--
Steve Roy <sroy at mac dot com>
Personal homepage: <http://homepage.mac.com/sroy>
Projects homepage: <http://www.roydesign.net>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>