1 16 package org.apache.commons.net; 17 18 import java.io.IOException ; 19 import java.util.Date ; 20 import java.io.DataInputStream ; 21 22 36 37 public final class TimeTCPClient extends SocketClient 38 { 39 40 public static final int DEFAULT_PORT = 37; 41 42 47 public static final long SECONDS_1900_TO_1970 = 2208988800L; 48 49 53 public TimeTCPClient () 54 { 55 setDefaultPort(DEFAULT_PORT); 56 } 57 58 76 public long getTime() throws IOException 77 { 78 DataInputStream input; 79 input = new DataInputStream (_input_); 80 return (long)(input.readInt() & 0xffffffffL); 81 } 82 83 99 public Date getDate() throws IOException 100 { 101 return new Date ((getTime() - SECONDS_1900_TO_1970)*1000L); 102 } 103 104 } 105 106 | Popular Tags |