Convert UTC to current locale time

后端 未结 7 1138
时光取名叫无心
时光取名叫无心 2020-11-27 03:20

I am downloading some JSON data from a webservice. In this JSON I\'ve got some Date/Time values. Everything in UTC. How can I parse this date string so the result Date objec

7条回答
  •  孤街浪徒
    2020-11-27 03:23

    A Date object is always a wrapper around milliseconds since epoch 0 in UTC. It does never represent local time.

    That means that you need to create a second SimpleDateFormatter that creates a display string that is in local time.

    Edit: @Op. Note that the preffered class for date/time-formatting on Android is java.text.DateFormat

提交回复
热议问题