输入相对于GMT的时区偏移量,求这个特定时区的时间,修改下面程序实现
小巫技术博客 腾讯高级客户端工程师 博客专家认证 2012-06-18 10:49:55 public class ShowCurrentTime {
public static void main(String[] args) {
//获得从1970年1月1日0点到当前时间之间单位为毫秒的差值
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 = totalHours % 60;
//输出结果
System.out.println("Current time is " + currentHour + ":"
+ currentMinute + ":" + currentSecond + "GMT");
}
}