time conversion delphi to java

G

gab

hello,
Can I convert a delphi date to java date?

for example I've this date : 37773,84 (delphi format)
and i must convert this in java Date.

thanks all
 
R

Rhino

gab said:
hello,
Can I convert a delphi date to java date?

for example I've this date : 37773,84 (delphi format)
and i must convert this in java Date.

I know you can do what you want to do; I did it three years ago during a
project. I've just checked my source directory for the method I wrote to do
the conversion but I can't find it so I must have deleted it since I never
expected to work with Delphi again. Unfortunately, I can't remember the
technique well enough to describe it to you but I recall that it wasn't
terribly hard, just a few lines of code really.

I just wanted you to know that the conversion *can* be done, even if I can't
recall how to do it.

Rhino
 
A

Andy Flowers

gab said:
hello,
Can I convert a delphi date to java date?

for example I've this date : 37773,84 (delphi format)
and i must convert this in java Date.

thanks all

This might help. It's from the Delphi 7 help file

The integral part of a Delphi TDateTime value is the number of days that
have passed since 12/30/1899. The fractional part of the TDateTime value
is fraction of a 24 hour day that has elapsed.

Following are some examples of TDateTime values and their corresponding
dates and times:

0 12/30/1899 12:00 am
2.75 1/1/1900 6:00 pm
-1.25 12/29/1899 6:00 am
35065 1/1/1996 12:00 am

Given this you should be able to use a bit of maths to work it out.

In my rather simple mind it should be as easy as

Calendar c = Calendar.getInstance();

c.set(1899,11,30,0,0);// init delphi version of start of time
// months go 0..11

c.add(Calendar.DATE,37773); // add in the days
c.add(Calendar.MINUTE,(int)((60*24) * 0.84)); // add the minutes

SimpleDateFormat sdf = new SimpleDateFormat();
System.out.println(sdf.format(c.getTime())); // voila
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,166
Latest member
DollyBff32
Top