-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathShowCurrentTime.java
More file actions
46 lines (34 loc) · 1.39 KB
/
ShowCurrentTime.java
File metadata and controls
46 lines (34 loc) · 1.39 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
import java.util.Scanner;
public class ShowCurrentTime {
public static void main(String[] args)
{
long currentMilis = System.currentTimeMillis();
System.out.println("Current currentTimeMilli Second : " + currentMilis);
// for(int i =0; i< 100; i++)
// {
// try {
// Thread.sleep(100);
// }catch (InterruptedException e)
// {
// e.printStackTrace();
// }
// }
// long timeLapse = System.currentTimeMillis() - currentMilis;
// System.out.println("Process took time : " + timeLapse + " milliseconds.");
// obtain the total
long totalSecond = currentMilis / 1000;
//Obtain the current seconds in the minutes in the hour
long second = totalSecond % 60;
//obtain the current seconds in mn in the hour
long totalMinutes = totalSecond / 60;
//Obtain the current minutes in the hour
long minutes = totalMinutes % 60;
//Obtain the total hours from midnight, jan 1, 1970
long totalHours = totalMinutes / 60;
//Obtain the current hours in the day
long hours = totalHours % 24;
//output
System.out.println("current time : "+ hours +":"+ minutes + ":" + second + " GMT+00:00");
System.out.println("Current time: "+ (hours + 7) + ":" + minutes + ":" + second + " GMT+07:00 Phnom Penh");
}
}