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

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

Introduction

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

Prototype

long SECONDS_1900_TO_1970

To view the source code for org.apache.commons.net TimeTCPClient SECONDS_1900_TO_1970.

Click Source Link

Document

The number of seconds between 00:00 1 January 1900 and 00:00 1 January 1970.

Usage

From source file:ProtocolRunner.java

private static void handleTCPTime(
    TimeTCPClient client, ProtocolRunner runner) 
    throws IOException {
        long origTime = client.getTime();
            /*  ww  w .  jav a 2s  .c  o  m*/
        // remember that the long time returned from the server is the 
        // seconds since midnight Jan 1900 and Date in Java is number of
        // seconds since midnight Jan 1970. NET TCPClient provides the time
        // in both formats but you cannot call them both one after another
        // as the internal getDate uses getTime, but the line has already
        // been closed if you have called getTime before.
        runner.getTCPServerResponse().append(
        "Time returned from server: " +  origTime + "\r\n" +
        "Converted to Date: " + 
        new Date(((origTime) - TimeTCPClient.SECONDS_1900_TO_1970)*1000L));
}