Date and time continuous Learn programming Java

Lesson:

Additional Libraries


Exercise:

Date and time continuous 32


Objetive:

Create a program to display the current time in the upper right corner of the screen, with the following format:

12:52:03

it must pause for a second and display it again, in the same position.


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