Delphi tdatetime for Java Date / Calender

I have a question for you, Delphi cracks there.

My Java application communicates with the Delphi application. A Delphi application displays some date values ​​in its user interface that must be transferred to a Java application through a file.

But instead of UTC or some kind of time line, the delphi application exports some floating point numbers, which, as I expect, will only be internal tdatetime date values.

This is shown below using the format MM / dd / YYYY:

  • User: 07/10/2014 → Export: 41919.00
  • User Interface: 05/31/2017 → Export: 42887.00
  • User Interface: 09/30/2015 → Export: 42,277.00
  • User Interface: 08/31/2016 → Export: 42613.00

I know that the tdatetime value in Delphi uses 30/12/1899 as a reference.

So I was expecting the following snapshot of the code to do the trick:

Calendar c = Calendar.getInstance();

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

c.add(Calendar.DATE, <FloatingPoint>); // add in the days
// minutes not required as all values end with .00

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

But to my surprise, this is not true.

  • Export: 41919.00 → Java: 10/07/14 00:00 (true)
  • Export: 42887.00 → Java: 06/01/17 00:00 (fail, +1 day)
  • Export: 42277.00 → Java: 09/30/15 00:00 (true)
  • Export: 42613.00 → Java: 08/31/16 00:00 (correct)

So what happened to my code snippet and conversion?

In fact, I do not have the application itself, just screenshots of the user interface and exported files. Therefore, there is a small chance that the screenshot and export may not be entirely correct.

It also explains why

  • UI: 05/31/2017 → 42887.00, and sometimes 42886.00

? , Java Delphie, .

ms-. .

- delphi tdatetime java snipet, , - ?

+4
1
program Project1;

{$APPTYPE CONSOLE}

uses
  DateUtils;

var
  t : TDateTime;
  d : double;
begin
  t := EncodeDateTime(2017,05,31,0,0,0,0);
  d := t;
  WriteLn(d);
  ReadLn;
end.

42886, 42887, . , .

datetime .

+2

All Articles