【问题标题】:Android - Change UTC time to local time [duplicate]Android - 将UTC时间更改为当地时间[重复]
【发布时间】:2015-11-19 17:52:05
【问题描述】:

我从服务中获取 - 包含 UTC 时区日期的日期对象。

如何将其更改为当前手机时区?

【问题讨论】:

标签: android


【解决方案1】:

类似这样的:

SimpleDateFormat fmt = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss a");
Date getDateTime = fmt.parse(utcDateAndTime);
fmt.setTimeZone(TimeZone.getDefault());
String getLocalDateTime = fmt.format(getDateTime);
System.out.println("Local date/time: " + getLocalDateTime);

【讨论】:

    猜你喜欢
    • 2023-04-09
    • 2015-09-26
    • 2022-11-23
    • 1970-01-01
    • 2012-03-20
    • 1970-01-01
    • 1970-01-01
    • 2013-07-14
    • 2011-02-18
    相关资源
    最近更新 更多