Example usage for org.apache.commons.net TimeUDPClient getTime

List of usage examples for org.apache.commons.net TimeUDPClient getTime

Introduction

In this page you can find the example usage for org.apache.commons.net TimeUDPClient getTime.

Prototype

public long getTime(InetAddress host) throws IOException 

Source Link

Document

Same as getTime(host, DEFAULT_PORT);

Usage

From source file:ProtocolRunner.java

private static void handleUDPTime(
    TimeUDPClient client, ProtocolRunner runner) 
    throws IOException {
            //from  w  ww  .j av  a 2  s  .  c o m
    long origTime = client.getTime(InetAddress.getByName(
        runner.getUDPRemoteServer()));

    runner.getUDPServerResponse().append(
    "Time returned from server: " +  origTime + "\r\n" +
    "Converted to Date: " + 
    new Date(((origTime) - TimeUDPClient.SECONDS_1900_TO_1970)*1000L));
}