New java time api ? (Date vs Instant)

Hello everyone,

I would like to know if it is planned or discussed to add/replace the use of Date java object by the new Instant java class.

For example, from AbsoluteDate, there is method to obtain a Date object (precision at 1 millisecond) whereas the Instant, from new java time api, is precise at 1 nanosecond.

Best regards,

Anne-Laure

Hi Anne-Laure,

I don’t know of any plans. I will add that the Instant class is documented to use a strange time scale, UTC-SLS, which changes the duration of a second near leap seconds. Whether anyone uses it in the manner documented is an open question. The Java Clock interface does not specify any accuracy requirements (so implementations can just ignore leap seconds to be accurate to 1 s) and conversion from other time sources to UTC-SLS is up to the user.

https://docs.oracle.com/javase/8/docs/api/java/time/Instant.html

Regards,
Evan

Hi Evan,

Thank you for you reply, it is more clear why Orekit should not migrate to the new api.

Best regards,

Hi Anne-Laure,

I’m not saying we shouldn’t support converting an Instant to an AbsoluteDate. I do think we would need the user to specify the TimeScale, just as with the current API for converting a Date. And it would be good to add a UtcSls time scale so the user could use the documented time scale, though I expect in most cases the time scale is actually UTC. But that can be left to the user to figure out which time scale their Instants are in.

Perhaps you could create a feature issue for it on the Orekit Gitlab?

Regards,
Evan