-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDialogTimer2.java
More file actions
55 lines (46 loc) · 2.61 KB
/
DialogTimer2.java
File metadata and controls
55 lines (46 loc) · 2.61 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import javax.swing.JOptionPane;
import java.util.GregorianCalendar;
/**
* DialogTimer
*/
public class DialogTimer2 {
public static final short MILISECONDS_IN_SECOND = 1000;
public static void main(String[] args) {
byte time1Seconds, time2Seconds, time1Minutes, time2Minutes, time1Hours, time2Hours;
short time1Miliseconds, time2Miliseconds;
int timeDifferenceInMiliseconds, timeDifferenceInSeconds, timeDifferenceInMinutes, timeDifferenceInHours;
GregorianCalendar time1 = new GregorianCalendar();
time1Miliseconds = (short)time1.get(GregorianCalendar.MILLISECOND);
time1Seconds = (byte)time1.get(GregorianCalendar.SECOND);
time1Minutes = (byte)time1.get(GregorianCalendar.MINUTE);
time1Hours = (byte)time1.get(GregorianCalendar.HOUR_OF_DAY);
JOptionPane.showConfirmDialog(null, "Is Stealing ever justified ?");
GregorianCalendar time2 = new GregorianCalendar();
time2Miliseconds = (short)time2.get(GregorianCalendar.MILLISECOND);
time2Seconds = (byte)time2.get(GregorianCalendar.SECOND);
time2Minutes = (byte)time2.get(GregorianCalendar.MINUTE);
time2Hours = (byte)time2.get(GregorianCalendar.HOUR_OF_DAY);
timeDifferenceInMiliseconds = time2Miliseconds - time1Miliseconds;
timeDifferenceInSeconds = time2Seconds - time1Seconds;
timeDifferenceInMinutes = time2Minutes - time1Minutes;
timeDifferenceInHours = time2Hours - time1Hours;
if(timeDifferenceInMiliseconds>0)
{
if(timeDifferenceInSeconds>0)
{
if(timeDifferenceInMinutes>0)
{
if (timeDifferenceInHours>0)
{
JOptionPane.showMessageDialog(null, "It took you " + timeDifferenceInHours + "H:" + timeDifferenceInMinutes + "M:"
+ timeDifferenceInSeconds + "S:" + timeDifferenceInMiliseconds + "MIL to answer.");
}
else JOptionPane.showMessageDialog(null, "It took you " + timeDifferenceInMinutes + "M:"
+ timeDifferenceInSeconds + "S:" + timeDifferenceInMiliseconds + "MIL to answer.");
}
else JOptionPane.showMessageDialog(null, "It took you " + timeDifferenceInSeconds + "S:" + timeDifferenceInMiliseconds + "MIL to answer.");
}
else JOptionPane.showMessageDialog(null, "It took you " + timeDifferenceInMiliseconds + "MIL to answer.");
}
}
}