https://www.codelovers.cn/tools/unix.html
https://blog.csdn.net/weixin_41919486/article/details/122428892
/
@author: qzf
@date: 2022/4/14 15:38
@describe: UTC时间戳(秒)转北京时间 ,北京时间 = UTC时间+8小时
@param:
@return:
/
public static String UTCTimeStamp2BeiJing(long ts){
//Long unixtimestamp = 1641537092L + 86060;
Long unixtimestamp = ts + 86060;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”);
simpleDateFormat.setTimeZone(TimeZone.getTimeZone(“GMT”));
String format1 = simpleDateFormat.format(new Date(unixtimestamp * 1000));
return format1;
}
/
@author: qzf
@date: 2022/4/14 15:38
@describe: 北京时间转UTC时间戳(秒) ,北京时间 = UTC时间+8小时
@param:
@return:
/
public static long BeiJing2UTCTimeStamp(String date) throws ParseException {
//Long unixtimestamp = 1641537092L + 86060;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”);
simpleDateFormat.setTimeZone(TimeZone.getTimeZone(“GMT”));
Date d = simpleDateFormat.parse(date);
return d.getTime() / 1000 - 86060;
}