[英]how can i display current time in java using currentTimeMillis() method
i want to create a java program that displays the current time in GMT timezone using System.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);
}
}
I think this was answered on this post: How to transform currentTimeMillis to a readable date format? 我认为这已在这篇文章中得到解答: 如何将currentTimeMillis转换为可读的日期格式? [duplicate] [重复]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.