import javax.swing.JOptionPane;
public class ShowCurrentTime {
public static void main(String[] args) {
long totalMilliseseconds = System.currentTimeMillis();
long totalSeconds = totalMilliseseconds / 1000;
long currentSecond = totalSeconds % 60;
long totalMinutes = totalSeconds / 60;
int currentMinute = (int) (totalMinutes % 60);
long totalHours = totalMinutes / 60;
int currentHour = (int)(totalHours % 24);
String output = "Current time is " + currentHour + ":" + currentMinute + ":" + currentSecond;
System.out.println(output);
}
}
为什么结果和实际时间差八个小时呢?