I have access to TAI time with seconds and nano seconds - let me just called this T
.
I want to now create a java Instant
class corresponding to this value T
.
I've looked for the appropriate constructors to do this but no luck.
I have access to TAI time with seconds and nano seconds - let me just called this T
.
I want to now create a java Instant
class corresponding to this value T
.
I've looked for the appropriate constructors to do this but no luck.
I'd recommend looking at, or using, the code in the ThreeTen-Extra library that explicity handles TAI and UTC. Here is the Javadoc.
TaiInstant tai = TaiInstant.ofTaiSeconds(taiSecs, taiNanos);
Instant instant = tai.toInstant();
The second method applies UTC-SLS conversion.
If you have access to the time elements separately you could do something like this:
long millisecondsTime = 1262347200000l;
long nanoseconds = 10202;
Instant taiInstance = Instant.ofEpochMilli(millisecondsTime);
taiInstance = taiInstance.plus(Duration.ofNanos(nanoseconds));