Real Time Clock
Name : V. Sai
Roll num : 24XZ1A05B4
Introduction
This project is a console-based digital clock built in Java using Object-
Oriented Programming principles.
It continuously displays the current system time, updating every second
in the console window.
Objectives
• Apply Object-Oriented Programming (OOP) concepts in Java.
• Implement real-time functionality using loops and [Link]().
• Display current system time dynamically.
• Learn how to handle user interruptions.
Code
Import [Link];
import [Link];
import [Link];
public class IndiaTimeClock {
public static void main(String[] args) {
// Formatter for 12-hour format with AM/PM
DateTimeFormatter formatter = [Link](“hh:mm:ss a”);
// Timezone for India
While (true) {
// Get current time in India
ZonedDateTime indiaTime = [Link](indiaZone);
// Format time
String formattedTime = [Link](formatter);
// Display time on same line
[Link](“\r🕒 Current Time in India: “ + formattedTime);
Try {
[Link](1000);
} catch (InterruptedException e) {
[Link]€;
}
}
}
}
Output Example
🕒 Current Time: 10:15:42
🕒 Current Time: 10:15:43
🕒 Current Time: 10:15:44
🕒 Current Time: 10:15:45
... (updates every second)
Conclusion
This console-based Clock project is a simple demonstration of OOP
concepts in Java.
It helps beginners understand class structure, looping, and real-time
functionality.
The project can be extended easily into more complex applications like
digital clocks or alarm systems.
Thank you