其他分享
首页 > 其他分享> > 显示世界时间 GMT GMT+8

显示世界时间 GMT GMT+8

作者:互联网


     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 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;
    		
		  //Compue the current hour
		  long currentHour = totalHours % 24;
    		
		
		  System.out.println(“Current time is “ + currentHour + “:”
						   + currentMinute + “:” + currentSecond + “ GMT”);
		  //GMT +8
		  long newTotalHour = totalHours + 8;
		  long newCurrentHour = newTotalHour % 24;
    		
		  System.out.println(“Current time is “ + newCurrentHour + “:”
						   + currentMinute + “:” + currentSecond + “ GMT+8”);
    }
    ```

标签:显示,世界,Obtain,long,System,60,total,GMT
来源: https://www.cnblogs.com/doudou-20123/p/16245390.html