Skip to content

Commit

Permalink
Merge pull request #364 from chinmay7016/patch-1
Browse files Browse the repository at this point in the history
Create Alaram-clock
  • Loading branch information
kishanrajput23 authored Oct 21, 2023
2 parents e89d35c + ada20f2 commit 4486fd8
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Alaram_clock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import java.util.Timer;
import java.util.TimerTask;
import java.text.SimpleDateFormat;
import java.util.Date;

public class AlarmClock {

public static void main(String[] args) {
// Set the alarm time (24-hour format)
String alarmTime = "15:30"; // Change this to your desired alarm time

// Create a timer
Timer timer = new Timer();

// Define a task to be executed when the alarm time is reached
TimerTask task = new TimerTask() {
public void run() {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
String currentTime = sdf.format(new Date());
if (currentTime.equals(alarmTime)) {
System.out.println("Alarm! It's time to wake up!");
// You can replace the message with any action you want
}
}
};

0 comments on commit 4486fd8

Please sign in to comment.