Convert UTC into Local Time on Android

后端 未结 5 1676
眼角桃花
眼角桃花 2020-11-29 04:26

In my project, I have get the API response in json format. I get a string value of time in UTC time format like this Jul 16, 2013 12:08:59 AM.
I need to cha

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-29 04:49

    //your UTC time var
    long time = UTCtime;
    
    //convert it
    Time timeFormat = new Time();
    timeFormat.set(time+TimeZone.getDefault().getOffset(time));
    
    //use the value
    long localTime = timeFormat.toMillis(true);
    

提交回复
热议问题