ClockApplication.java Programming assign unit 3
ClockApplication.java Programming assign unit 3
CS 1103 Programming 2
May 1, 2024
package com.codewithMunyendo;
import java.text.SimpleDateFormat;
import java.util.Date;
class Clock {
// SimpleDateFormat to format the time and date
private SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss dd-
MM-yyyy");
// Constructor
public TimeUpdater(Clock clock) {
this.clock = clock;
}
@Override
public void run() {
// Continuously update the time
while (true) {
// For now, just sleep to simulate time updates
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// Handle interruption
System.out.println("Updater thread interrupted.");
}
}
}
}
OUTPUT