java将时间戳转换为UTC时区
public static long getCurrentEpochTimeStamp(String timeStamp) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.0Z'");
Date date = sdf.parse(timeStamp);
return date.getTime();
}
这个方法返回当前时间戳,我需要将其转换为UTC时区
# 1 楼答案
将时区设置为
SimpleDateFormat
对象