Calculation error when representing TDateTime (Delphi) as a Java Calendar object -
Calculation error when representing TDateTime (Delphi) as a Java Calendar object -
delphi tdatetime
epoch december 30, 1899, java calendar
uses unix epoch january 1, 1970. next code:
calendar epoch = calendar.getinstance(timezone.gettimezone("utc")); epoch.set(1899, 12, 30, 0, 0, 0); epoch.gettimeinmillis();
gives -2206483199054 according manual calculations has -2209161600000. delta 2678400946 (31 days) come from? missing?
yes, can operate milliseconds workaround want know error comes from.
p.s. epoch
instance of java.util.gregoriancalendar
.
the month field 0-based, dec month 11, not 12. explains why you're off 31 days — wrapped around jan 30, 1900. can phone call setlenient(false)
grab kind of error sometimes.
the set
method sets 6 fields mentioned in arguments; leaves other fields unchanged, including millisecond field, explains why you're off slightly more 31 days.
the documentation advises phone call clear()
first, may instead prefer phone call clear(calendar.millisecond)
maintain time-zone info intact.
java delphi
Comments
Post a Comment