因此,我現在嘗試了幾個小時來將時間戳轉換爲本地日期(CEST)。將UTC時間戳轉換爲本地日期
Date date = new Date(stamp*1000);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("CEST"));
String myDate = simpleDateFormat.format(date);
它不工作無論我嘗試在網上查找我總是回來UTC時間......
爲了更好的理解:郵票是long類型,我會一個變量時間戳從服務接收
這應該有所幫助:http://stackoverflow.com/questions/7670355/convert-date-time-for-given-timezone -java – Jens
我嘗試了11個upvotes的建議,因爲您可能已經看到,它不工作 – Nali
嘗試[this](http://stackoverflow.com/questions/19431234/converting-between-java-time-localdatetime-and-java -util-date) –