From 3140a8eac7ca77d1d8b6f99d74f23b054bb53d75 Mon Sep 17 00:00:00 2001 From: "ap9176@student.uni-lj.si" Date: Thu, 18 Dec 2014 14:23:24 +0000 Subject: rdate git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@103 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414 --- kpov_judge/tasks/custom_rdate/rDate.java | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 kpov_judge/tasks/custom_rdate/rDate.java (limited to 'kpov_judge/tasks/custom_rdate') diff --git a/kpov_judge/tasks/custom_rdate/rDate.java b/kpov_judge/tasks/custom_rdate/rDate.java new file mode 100644 index 0000000..8c8bae7 --- /dev/null +++ b/kpov_judge/tasks/custom_rdate/rDate.java @@ -0,0 +1,34 @@ +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStreamWriter; +import java.net.Socket; +import java.net.SocketException; +import java.nio.ByteBuffer; +import java.uti.Date; +import java.util.Scanner; + +public class rDate{ + + public static void main(String[] args) throw IOException{ + Scanner sc=new Scanner(System.in); + String niz=sc.next(); + + try{ + Socket s=new Socket(niz,37); + OutputStreamWriter izhod=new OutputStreamWriter(s.getOutputStream()); + InputStream vhod=s.getInputStream(); + byte[] podatek=new byte[4]; + ByteBuffer buf=ByteBuffer.wrap(podatek); + int stevilka=buf.getInt(); + long dolga=stevilka + long maska=-1; + maska =~(maska <<32); + dolga = dolga & maska; + Date d=new Date(dolga *1000 - 2208988800000L); + System.out.print(d); + izhod.write(d.toString()); + }catch(SocketException e){ + System.out.println("Strežnik ne obstaja"); + } + } +} -- cgit v1.2.1