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."); } } }