Date and time continuous Java Exercise - Java Programming Course

 Exercise

Date and time continuous

 Objetive

Create a program that shows the current time in the top-right corner of the screen with the format:

12:52:03

The program should pause for one second and then display the time again in the same location.

 Example Code

public class Main
{
	static void main(String[] args)
	{
		while (true)
		{
			String time = java.time.LocalDateTime.now().ToLongTimeString();

			Console.SetCursorPosition(72, 1);
			System.out.print(time);

			Thread.sleep(1000);
		}
	}
}


Juan A. Ripoll - Programming Tutorials and Courses © 2024 All rights reserved.  Legal Conditions.