import java.net.*;

public class GetDate {

  final static int PORT_DAYTIME = 13;  // well-known daytime port

  public static void main (String args[]) throws Exception {
    DatagramSocket  dgSocket;
    DatagramPacket  datagram;
    InetAddress     destination;
    byte msg[] = new byte[256];

    dgSocket   = new DatagramSocket();
    destination = InetAddress.getByName ("mam.gov.tr");

    datagram   = new DatagramPacket (msg, msg.length, destination,
                                     PORT_DAYTIME);
    dgSocket.send(datagram);

    datagram = new DatagramPacket (msg, msg.length);
    dgSocket.receive(datagram);

    String received = new String (datagram.getData());
    System.out.println ("TÜBİTAK MAM'da şu anda saat: " + received);

    dgSocket.close();

  }
} // end of class GetDate
