package DEMO01; import java.text.SimpleDateFormat; import java.util.Date; public class Demo5 { public static void main(String[] args) { while (true){ Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); System.out.println(sdf.format(date)); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } } }