悉尼當前時間: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