悉尼当前时间:2018/09/21 00:00:00
悉尼时区:GMT+10
时间戳(格林尼治时间):1537452000000
北京时间:2018/09/20 22:00:00
根据当前时区的时间转换为时间戳方法:
public static Date convertTimeZoneToDate(String time, String dateFormat, String timeZone) {
SimpleDateFormat bjSdf = new SimpleDateFormat(dateFormat);
bjSdf.setTimeZone(TimeZone.getTimeZone(timeZone));
try {
Date result = bjSdf.parse(time);
logger.info("time: {},dateFormat:{},timeZone:{},timestamp:{}", time, dateFormat, timeZone, result.getTime());
return result;
} catch (ParseException e) {
logger.error("toTimeZone failed!time: {},dateFormat:{},timeZone:{},e:{}", time, dateFormat, timeZone, e);
throw new RuntimeException("toTimeZone failed");
}
}
参考:
悉尼时区转换:https://www.epochconverter.com/timezones?q=1537452000&tz=Australia%2FSydney
本文介绍了悉尼和北京时间的转换方法,提供了将特定时间格式和时区转换为时间戳的Java代码示例,并链接了悉尼和北京时间戳转换的在线工具。
622

被折叠的 条评论
为什么被折叠?



