import java.io.*; import java.net.*; import java.util.Calendar; import java.util.Vector; public class Jututuba { public String kellaaeg() { String vastus = new String(); Calendar aeg = Calendar.getInstance(); String tund = Integer.toString(aeg.get(Calendar.HOUR_OF_DAY)); String minut = Integer.toString(aeg.get(Calendar.MINUTE)); String sekund = Integer.toString(aeg.get(Calendar.SECOND)); if (tund.length() == 1) tund = "0" + tund; if (minut.length() == 1) minut = "0" + minut; if (sekund.length() == 1) sekund = "0" + sekund; vastus = "[" + tund + " : " + minut + " : " + sekund + "]"; return vastus; } // kellaaeg public static void main(String argumendid[]) throws IOException { ServerSocket ss = new ServerSocket(23); Vector uhendused = new Vector(); System.out.println(new Jututuba().kellaaeg() + " Server töötab praegu."); while (true) { Socket sc = ss.accept(); uhendused.add(sc); new JututoaLoim(sc, uhendused); } // while } // peameetod }