How to convert UTC timestamp to device local time in android

后端 未结 9 1870
孤独总比滥情好
孤独总比滥情好 2020-11-29 21:24

I need to convert the UTC time stamp that i get from the server to local device time. currently i get 5 hrs difference in my time. for example when i post to server the post

9条回答
  •  借酒劲吻你
    2020-11-29 21:49

    int offset = TimeZone.getDefault().getRawOffset() + TimeZone.getDefault().getDSTSavings();
    long now = System.currentTimeMillis() + offset;
    

提交回复
热议问题