An implementation of java.time.InstantSource independent of the local clock and synchronized with an NTP server.
Maven configuration:
<dependency>
<groupId>tech.kage.time</groupId>
<artifactId>tech.kage.time.ntp</artifactId>
<version>1.0.0</version>
</dependency>module-info.java
module my.simple.mod {
requires tech.kage.time.ntp;
}Initialize instant source
String ntpServer = "pool.ntp.org";
java.time.InstantSource instantSource = new NtpSynchronizedInstantSource(ntpServer);
((NtpSynchronizedInstantSource) instantSource).sync();Get the current instant
java.time.Instant now = instantSource.instant();This project is released under the BSD 2-Clause License.