悉尼当前时间: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