[英]How to get the execution time in small fraction using currentTimeMillis() method
[英]how can i display current time in java using currentTimeMillis() method
我想創建一個Java程序,使用System.currentTimeMillis()
方法在GMT時區中顯示當前時間。
public class DisplayTime {
public static void main(String[] args){
long totalMilliSeconds = System.currentTimeMillis();
long totalSeconds = totalMilliSeconds / 1000;
long currentSecond = totalSeconds % 60;
long totalMinutes = totalSeconds / 60;
long currentMinute = totalMinutes % 60;
long totalHours = totalMinutes / 60;
long currentHour = totalMinutes % 12;
System.out.println(currentHour + " : " + currentMinute + " : " + currentSecond);
}
}
我認為這已在這篇文章中得到解答: 如何將currentTimeMillis轉換為可讀的日期格式? [重復]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.