-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStartThread.java
More file actions
35 lines (31 loc) · 1000 Bytes
/
StartThread.java
File metadata and controls
35 lines (31 loc) · 1000 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.util.*;
import java.text.*;
public class StartThread implements Runnable
{
//Reference to Start object
Start start;
public StartThread(Start s)
{
start=s; //Getting reference to Start
}
//Thread function - it runs when thread on this object is started
public void run()
{
boolean flag=true;
while(flag) //does while flag is true
{
//Gets date in US format with default timezone
DateFormat df=new SimpleDateFormat("dd MMM yyyy HH:mm:ss", Locale.US);
// df.setTimeZone(TimeZone.getTimeZone(System.getProperty("user.timezone")));
df.setTimeZone(TimeZone.getTimeZone("ECT"));
Calendar c=Calendar.getInstance();
//Shows date and time in Start's label with Start's showDate method
start.showDate(df.format(c.getTime()));
//Waits 1 second and repeats it
try
{ Thread.sleep(1000); }
catch(InterruptedException e)
{ flag=false; }
}
}
}