Convert UTC to current locale time

后端 未结 7 1133
时光取名叫无心
时光取名叫无心 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:34

    public static String toLocalDateString(String utcTimeStamp) {
        Date utcDate = new Date(utcTimeStamp);
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
        df.setTimeZone(TimeZone.getTimeZone("PST"));
        return df.format(utcDate);
    }
    

    Cheers!

提交回复
热议问题