In a recent project, Java and Delphi were used to find that they could not read the date type correctly, such as writing a date value of "2007-12-1" in Java, which is not the value of Delphi reading.
By looking at the data, it was found that the definitions for date types were slightly different. The date in Java is stored using a long integer, which represents the number of milliseconds from "1970-1-1". For example, "1970-1-2" is 86400000 milliseconds after "1970-1-1", so 86400000 is used in Java to represent the "1970-1-2" date. Since the long integer is signed, we can use a negative number of milliseconds to represent the date before "1970-1-1". The dates in Delphi are stored using a double type, the integer part represents the number of days from "1899-12-30", and the fractional part represents the hour. The value "2.75" means "1900-1-1 6:00pm" and "1.25" means "1899-12-29".
Because the date type differs from the start date, the same "0" value represents a different date in both. Then a conversion is needed to communicate the date value between Java and Delphi.
//Convert a date in Java to a date in DelphifunctionConvertjavadatetimetodelphidatetime (Value:int64): Tdatetime;beginResult:= Incmillisecond (Strtodate ('1970-1-1'), Value);End;//Convert a date in Delphi to a date in JavafunctionConvertdelphidatetimetojavadatetime (adatetime:tdatetime): Extended;beginResult:= Millisecondspan (Adatetime, Strtodate ('1970-1-1'))End;
Reference: http://blog.csdn.net/chris_mao/article/details/1921864
Delphi and date Interchange in Java