Skip to content

An implementation of java.time.InstantSource independent of the local clock and synchronized with an NTP server.

License

Notifications You must be signed in to change notification settings

kagetech/time-source

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NTP synchronized time source

An implementation of java.time.InstantSource independent of the local clock and synchronized with an NTP server.

Getting started

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();

License

This project is released under the BSD 2-Clause License.

About

An implementation of java.time.InstantSource independent of the local clock and synchronized with an NTP server.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages