Output
Variable Name   Value in Memory
1 public class ShowCurrentTime {
2 public static void main(String[] args) {
3
4 long totalMilliseconds = System.currentTimeMillis();
5
6
7 long totalSeconds = totalMilliseconds / 1000;
8
9
10 long currentSecond = totalSeconds % 60;
11
12
13 long totalMinutes = totalSeconds / 60;
14
15
16 long currentMinute = totalMinutes % 60;
17
18
19 long totalHours = totalMinutes / 60;
20
21
22 long currentHour = totalHours % 24;
23
24
25 System.out.println("Current time is " + currentHour + ":"
26 + currentMinute + ":" + currentSecond + " GMT");
27 }
28 }