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();
}
Run Code Online (Sandbox Code Playgroud)
此方法返回纪元当前时间戳,我需要将其转换为UTC时区。
为您的SimpleDateFormat 对象设置时区。
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19278 次 |
| 最近记录: |