将时间戳转换为UTC时区 [英] Convert timestamp to UTC timezone
本文介绍了将时间戳转换为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时区。
This method returns epoch current timestamp, I need to convert this to UTC timezone.
推荐答案
将时区设置为 SimpleDateFormat
对象。
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
这篇关于将时间戳转换为UTC时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文