SntpClient { public static synchronized Timing requestTime(final String host, final int timeoutMillis) throws IOException { return requestTime(host, NTP_PORT, timeoutMillis); } private  SntpClient(); static Timing requestTimeHA(final int timeoutMillis, final String... hosts); static Timing requestTimeHA(final int timeoutMillis,
          final int ntpResponseTimeoutMillis, final String... hosts); static Timing requestTimeHA(final int timeoutMillis,
          final int ntpResponseTimeoutMillis, final int port, final String... hosts); static Timing requestTimeHA(final int timeoutMillis,
          final int ntpResponseTimeoutMillis, final int port, final InetAddress... hosts); static synchronized Timing requestTime(final String host, final int timeoutMillis); @SuppressFBWarnings("NP_LOAD_OF_KNOWN_NULL_VALUE") // false positive static Timing requestTime(final String host, final int port, final int timeoutMillis); @SuppressFBWarnings("NP_LOAD_OF_KNOWN_NULL_VALUE") // false positive static Timing requestTime(final String host, final int port, final long deadlineNanos); @SuppressFBWarnings("NP_LOAD_OF_KNOWN_NULL_VALUE") // false positive static synchronized Timing requestTime(final InetAddress address, final int port, final long deadlineNanos);  }
@Test public void test2() throws IOException { try (Closeable runUdpServer = runUdpServer(false)) { Timing timing = SntpClient.requestTime("localhost", 50123, 20); long currentTimeMachine = System.currentTimeMillis(); long currentTimeNtp = timing.getTime(); LOG.debug("Current Timing = {} ", timing); LOG.debug("Current time machine = {} ", Instant.ofEpochMilli(currentTimeMachine)); LOG.debug("Current time ntp = {} ", Instant.ofEpochMilli(currentTimeNtp)); Assert.assertTrue(Math.abs(currentTimeNtp - currentTimeMachine) < 10000); } }