Created
December 22, 2016 14:42
-
-
Save abdalimran/577aa4217d895cea7a15e1749359ed03 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Date; | |
import java.text.DateFormat; | |
import java.text.SimpleDateFormat; | |
public class ThreadEvents implements Runnable | |
{ | |
final long timeInterval = 60*1000; | |
private Thread theThread; | |
public void start() | |
{ | |
if (theThread == null) | |
{ | |
System.out.println("Thread has been started"); | |
theThread = new Thread(this); | |
theThread.start(); | |
} | |
} | |
@Override | |
public void run() | |
{ | |
while(true) | |
{ | |
LoadEventData led=new LoadEventData(); | |
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm a"); | |
Date date = new Date(); | |
String td = dateFormat.format(date); | |
for (int i = 0; i < led.eventList.size(); i++) { | |
int eid = led.eventList.get(i).getID(); | |
String ename = led.eventList.get(i).getName(); | |
String edate = led.eventList.get(i).getDate(); | |
String etime = led.eventList.get(i).getTime(); | |
String edetails = led.eventList.get(i).getDetails(); | |
EventClass ev=new EventClass(eid,ename,edate,etime,edetails); | |
String etd=ev.getDate()+" "+ev.getTime(); | |
if(td.equals(etd)==true) | |
{ | |
new NotifyEvent(ev.printAllDetails()); | |
System.out.println("Now you have an event."); | |
System.out.println(ev.printAllDetails()); | |
} | |
} | |
try { | |
Thread.sleep(timeInterval); | |
} | |
catch (InterruptedException e) | |
{ | |
e.printStackTrace(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment