Java SimpleDateFormat(“yyyy-MM-dd'T'HH:mm:ss'Z”))给出时区为IST [英] Java SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'") gives timezone as IST

查看:636
本文介绍了Java SimpleDateFormat(“yyyy-MM-dd'T'HH:mm:ss'Z”))给出时区为IST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有SimpleDateFormat构造函数作为

I have SimpleDateFormat constructor as

SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'")

我正在解析字符串2013-09-29T18: 46:19Z。

我读过这里Z代表 GMT / UTC 时区。但是当我在控制台上打印此日期时,它将为返回的日期打印IST timezne。

I have read that here Z represents the GMT/UTC timezone. but when I print this date on console , It prints IST timezne for the returned date.

现在我的问题是我的输出是对还是错?

Now my question is whether my output is right or wrong?

推荐答案

您尚未设置时区,仅在日期结束时添加了 Z /时间,所以它看起来像一个GMT日期/时间,但这不会改变这个值。

You haven't set the timezone only added a Z to the end of the date/time, so it will look like a GMT date/time but this doesn't change the value.

将时区设置为GMT,这将是正确的。 p>

Set the timezone to GMT and it will be correct.

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));

这篇关于Java SimpleDateFormat(“yyyy-MM-dd'T'HH:mm:ss'Z”))给出时区为IST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆