Friday, January 13, 2017

Program to display clock in console window

import java.util.*;
class SystemTime
{

public static void main(String...args) throws Exception
{
System.out.println("type ctrl and c to quit");
for(;;)
{
//Create the object.
Date d=new Date();
//Display the System time and date.
System.out.print(d);
// hold the next time.
Thread.sleep(500);
//To overide the previous time and move cursor to starting point.
System.out.print("\r");
Thread.sleep(500);
}
}
}

                                                                                                                                  

Output:


No comments:

Post a Comment