日期:将格林尼治时间(GMT)转化为北京时间

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/jiaonizuoren/article/details/82983596

        格里尼治时间,就是我们常常说的0度经线的地方平时,也叫格林平时,格林平时的英文是Greenwich Mean Time,简称GMT,实际上就是UT(universal time )也叫世界时的。

        从0度格林经线到120度东八区时区经线,经差为120度,换算成时间为8小时(120除以15),所以格林平时和北京时间差八小时,而且是北京时间比格林平时快8小时,因此是在格林平时的基础上加8小时的,代码如下:

Calendar calendar = Calendar.getInstance();
calendar.setTime(createDate);
calendar.set(Calendar.HOUR, calendar.get(Calendar.HOUR) + 8);
createDate = calendar.getTime();

猜你喜欢

转载自blog.csdn.net/jiaonizuoren/article/details/82983596
今日推荐