summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbb3600@student.uni-lj.si <bb3600@student.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2015-01-23 16:48:52 +0000
committerbb3600@student.uni-lj.si <bb3600@student.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2015-01-23 16:48:52 +0000
commit5ff47bd71a15a947b215ed8509321e7b18568514 (patch)
treecef025231d64090c393a24c43e65a1fdf6fe4743
parentdd4cb3b6d6115eed555b6678ccc2877a1df6543a (diff)
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@227 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
-rw-r--r--kpov_judge/tasks/custom_rdate/CustomRDate.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/kpov_judge/tasks/custom_rdate/CustomRDate.java b/kpov_judge/tasks/custom_rdate/CustomRDate.java
new file mode 100644
index 0000000..426dece
--- /dev/null
+++ b/kpov_judge/tasks/custom_rdate/CustomRDate.java
@@ -0,0 +1,21 @@
+import java.io.InputStream;
+import java.net.Socket;
+import java.nio.ByteBuffer;
+import java.util.Date;
+
+public class CustomRDate {
+ public static void main(String main[]) throws Exception{
+ try {
+ Socket s = new Socket("ntp1.arnes.si", 37);
+ InputStream vhod = s.getInputStream();
+ byte podatek[] = new byte[8];
+ int dejanskoPrebranih = vhod.read(podatek, 4, 4);
+ ByteBuffer buf = ByteBuffer.wrap(podatek);
+ long stevilka = buf.getLong() - 2208988800L;
+ Date d = new Date(stevilka*1000);
+ System.out.println(d);
+ } catch(Exception e) {
+ System.out.println("Nedosegljiv streznik.");
+ }
+ }
+} \ No newline at end of file