public class ShowCurrentTime {
public static void main (String[] args) {
//Obtain the total milliseconds since midnight, Jan 1. 1970
long totalMillisencods = System.currentTimeMillis();
//Obtain the total second in the midnight , Jan 1, 1970
long totalSeconds = totalMillisencods / 1000;
//Obtain the current second int the minute int the hour
long currentSecond = totalSeconds % 60;
//Obtain the total mintes
long totalMinutes = totalSeconds / 60;
//Computer the current minute in the hour
long curentMinute = totalMinutes % 60;
//Obtain the total hours
long totalHours = totalMinutes / 60;
//computer the current hour
long currentHour = totalHours %24;
//display results
System.out.println ("Current time is " + currentHour + ":"
+ curentMinute + " : " + currentSecond + " GMT");
}
}
(每日一java)ShowCurrentTime 显示系统时间
最新推荐文章于 2021-02-26 10:27:39 发布