2016年7月21日 星期四

UTC String to Local Time



有時候JSON回傳的時間資料為UTC字串
可利用以下程式碼轉換成 西元當地時間


int time = Integer.parseInt("JSON Time");

String mDate = new SimpleDateFormat("yyyy/MM/dd").format(new Date(time * 1000L));

System.out.print(mDate);

-> 2016/07/22

沒有留言:

張貼留言