【问题标题】:Android simpledateformat not working properlyAndroid simpledateformat 无法正常工作
【发布时间】:2011-07-04 10:48:25
【问题描述】:

所以我将当前时间转换为UTC时间格式的代码如下:

Date currentDate = Calendar.getInstance().getTime();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
String UTCTime= sdf.format(currentDate);

但由于某种原因它不起作用,它仍然在我的时区而不是 UTC 时区给出当前时间。有谁知道是什么原因造成的?

【问题讨论】:

    标签: android timezone


    【解决方案1】:

    显然代码是有效的,我的手机设置了错误的时区

    【讨论】:

      猜你喜欢
      • 2017-03-30
      • 1970-01-01
      • 2017-03-10
      • 2012-09-13
      • 2012-03-24
      • 2012-11-03
      • 2013-11-24
      • 1970-01-01
      相关资源
      最近更新 更多