Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static final String NTP_SERVER = "ntp4.stratum1.ru";
- /**
- * Get atomically correct current date from stratum 1 NTP-server
- *
- * @return system time with computed delta between system time and NTP-server
- * @throws IOException
- */
- public Date getAtomicallyCorrectDate() throws IOException {
- NTPUDPClient client = new NTPUDPClient();
- TimeInfo time = client.getTime(InetAddress.getByName(NTP_SERVER));
- time.computeDetails();
- return new Date(System.currentTimeMillis() + time.getOffset());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement