Skip to content

Java Clock that displays Current Time, Day and Date

License

Notifications You must be signed in to change notification settings

jjoslin07/Clock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Clock

Java Clock that displays Current Time, Day and Date

Screenshot

Screen Shot 2022-04-12 at 9 59 54 PM

Method

	// Method to set the time and update every 1000ms
	public void setTime() {
		// Continuous loop to check time, day and date
		while (true) {
			// Get current time and set to timeLabel
			time = timeFormat.format(Calendar.getInstance().getTime());
			timeLabel.setText(time);

			// Get current day and set to dayLabel
			day = dayFormat.format(Calendar.getInstance().getTime());
			dayLabel.setText(day);

			// Get current date and set to dateLabel
			date = dateFormat.format(Calendar.getInstance().getTime());
			dateLabel.setText(date);

			// try catch block to sleep loop every 1000ms
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}

		}
	}

Demo

Screen.Recording.2022-04-12.at.10.31.37.PM.mov

About

Java Clock that displays Current Time, Day and Date

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages