Example usage for org.apache.commons.net TimeTCPClient getDate

List of usage examples for org.apache.commons.net TimeTCPClient getDate

Introduction

In this page you can find the example usage for org.apache.commons.net TimeTCPClient getDate.

Prototype

public Date getDate() throws IOException 

Source Link

Document

Retrieves the time from the server and returns a Java Date containing the time converted to the local timezone.

Usage

From source file:examples.rdate.java

public static final void timeTCP(String host) throws IOException {
    TimeTCPClient client = new TimeTCPClient();

    // We want to timeout if a response takes longer than 60 seconds
    client.setDefaultTimeout(60000);/*www.ja v  a  2  s .  c  o  m*/
    client.connect(host);
    System.out.println(client.getDate().toString());
    client.disconnect();
}