Convert UTC date to current timezone

前端 未结 5 1209
广开言路
广开言路 2021-01-27 02:51

I have to convert a UTC date in this format \"2016-09-25 17:26:12\" to the current time zone of Android. I did this:

SimpleDateFormat simpleDateFormat = new Simp         


        
5条回答
  •  误落风尘
    2021-01-27 03:18

    You can do it with set timezone method.

    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
    Date myDate = simpleDateFormat.parse(rawQuestion.getString("AskDateTime"));
    

提交回复
热议问题