[問題] JAVA時間顯示錯誤

作者: RicciYeh (RicciYeh)   2019-03-02 21:59:48
教科書的內容是 顯現現在的時間 可是我照著打 為什麼時間會出錯?
public class ShowCurrentTime{
public static void main(String[] args){
// obtain the total milliseconds since midnight, jan 1, 1970
long totalMilliseconds = System.currentTimeMillis();
// obtain the total seconds since midnight, jan 1, 1970
long totalSeconds = totalMilliseconds / 1000;
// Compute the current second in the minute in the hour
long currentSecond = totalSeconds % 60;
// Obtain the titak minutes
long totalMinutes = totalSeconds / 60;
// Compute the current minute in the hour
long currentMinute = totalMinutes % 60;
// Obtain tje total hours
long totalHours = totalMinutes / 60;
// Compute the current Hour
long currentHour = totalHours % 24;
// 這行是我自己上網找的 確定一下我的時間
System.out.print("Current time is "+new java.util.Date( System.currentTimeMillis() )+"\n");
// Display results
System.out.println("Current time is " + currentHour + ":" + currentMinute + ":" + currentSecond + " GMT");
}
}
輸出:
Current time is Sat Mar 02 21:55:39 CST 2019
Current time is 13:55:39 GMT
想請問各位大神這個是哪裡出錯?

Links booklink

Contact Us: admin [ a t ] ucptt.com