我試圖將UTC日期/時間字符串轉換爲另一個時區。它只顯示UTC時區的日期/時間。下面無法將UTC的日期轉換爲另一個時區
代碼:
apiDate = "2013-04-16T16:05:50Z";
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss'Z'");
Date date = dateFormat.parse(apiDate);
Calendar calendar = Calendar.getInstance();
TimeZone timeZone = calendar.getTimeZone();
SimpleDateFormat newDateFormat = new SimpleDateFormat("hh:mm aa, MMMM dd, yyyy");
newDateFormat.setTimeZone(timeZone);
String newDateString = newDateFormat.format(date);
[將UTC日期轉換爲其他時區]可能的重複(http://stackoverflow.com/questions/6088778/converting-utc-dates-to-other-timezones) –
是的,它實際上是重複的。對不起,我確實花了很長時間尋找答案,但我並沒有偶然發現。不管怎麼說,還是要謝謝你 ! –
當您鍵入您的問題主題時,它會自動彈出,這也是爲什麼它也是此屏幕右側的頂部鏈接。 –