For implementing a “w” message in the OpenAMIP 1.17 specification [1], I need to calculate utcOffset defined as integer time difference in seconds between UTC time and GPS time at the time the “w” message is sent i.e. java.util.Date now = new java.util.Date().
I wrote the following Orekit code but I see that the AbsoluteDate constructor I’m using for the GPSScale line [2] is deprecated [public AbsoluteDate(final Instant instant, final TimeScale timeScale)]. I’m not sure the correct way to write this code without using this deprecated constructor. Would someone be able to help?
private long getUtcOffset(TimeUnit timeUnit) {
GPSScale gps = TimeScalesFactory.getGPS();
UTCScale utc = TimeScalesFactory.getUTC();
Instant now = ZonedDateTime.now( ZoneOffset.UTC ).toInstant();
AbsoluteDate nowUtc = new AbsoluteDate(now, utc);
AbsoluteDate nowGps = new AbsoluteDate(now, gps); // <<<<< 2
return nowUtc.durationFrom(nowGps, timeUnit);
}
1 - https://www.idirect.net/wp-content/uploads/2021/02/OpenAMIP-Standard-Version-1-17-Revision-F.pdf