diff options
Diffstat (limited to 'kpov_judge')
-rw-r--r-- | kpov_judge/tasks/custom_rdate/rDate.java | 34 |
1 files changed, 34 insertions, 0 deletions
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"); + } + } +} |