0

I have a java program which makes a JNI call. From java, I am sending Date.getTime() (basically seconds * 1000), and I expect C++ to convert it to a perfect date.

NOT DUPLICATE: I KNOW MANY SOLUTIONS EXIST ON STACKOVERFLOW, BUT NONE OF THEM SEEM TO WORK WITH DATES SINCE 01-01-0001

I need the dates to get perfectly generated, for as early as 01-01-0001 00:00:00.

Any clue or code snippet in C++?

chaity
  • 163
  • 2
  • 11

1 Answers1

1

This assumes that getTime() works according to the java docs outputting time since 1970. Try this: How can I convert seconds since the epoch to hours/minutes/seconds in Java?

(Edit: even though the question is for Java the implementation given in the first answer is in C, which is (mostly) valid C++ code. It doesn't account for leap seconds so just subtract the number of leap seconds since 1970 before evaluating)

Community
  • 1
  • 1
Viktor
  • 155
  • 8