可以加入GTM时间,代码如下:
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 in midnight,Jan 1, 1970
long totalSeconds=totalMilliseconds/1000;
//compute the current second in the minute in the hour
long currentSecond=totalSeconds%60;
//Obtain the total minutes
long totalMinutes=totalSeconds/60;
//compute the current minute in the hour
long currentMinute=totalMinutes%60;
//Obtain the total hours
long totalHours=totalMinutes/60;
//compute the current hour
long currentHour=totalHours%24;
//display results
System.out.println("Current time is "+currentHour+" : "+currentMinute+" : "+currentSecond+" GMT");
}
}
取消
评论