Java convert millisecond timestamp to date with respect to given timezone

后端 未结 4 1712
北海茫月
北海茫月 2021-01-15 12:58

I have seen many resources on this but one thing I cant get is when converting the millisecond timestamp, how I add a corresponding time zone, during the conversion process.

4条回答
  •  Happy的楠姐
    2021-01-15 13:30

    I was doing a similar thing in my previous project.You can use setTimeZone method of SimpleDateFormat class. Something like this :

    mydate.setTimeZone(TimeZone.getTimeZone("GMT -0400"));
    

提交回复
热议问题