如何创建没有时区的 java.sql.timestamp
(我得到 2007-09-23T10:10:10Z
并且我假装 2007-09-23T10:10:10
).
How can I create a java.sql.timestamp
without timezone (i´m getting 2007-09-23T10:10:10Z
and I pretend 2007-09-23T10:10:10
).
我试试:
Timestamp timestamp = Timestamp.valueOf("2007-09-23 10:10:10");
但在调试中我看到 cdate 是 2007-09-23T10:10:10.000+0100
而不是 2007-09-23T10:10:10
p>
but in debug i saw that the cdate is 2007-09-23T10:10:10.000+0100
instead of 2007-09-23T10:10:10
时间戳没有时区.当您将时间戳显示为字符串时,它会显示时间并提及时区,因为否则您无法知道它代表什么时间.它选择使用默认时区(您的),因为那是您最熟悉的.
A Timestamp doesn't have a timezone. When you display the timestamp as a String, it displays a time and mentions the timezone, because else you couldn't know what time it represents. And it chooses to use the default timezone (yours), because that's the one you're the most familiar with.
说,现在是 12:00:00 没有任何意义.说你的时区是 12:00:00 意味着什么.但是时间戳只包含一个瞬间.您可以使用 DateFormat 在您想要的任何时区显示这一瞬间.
Saying, it's 12:00:00 doesn't mean anything. Saying it's 12:00:00 in your timezone means something. But the timestamp only contains an instant in time. You may display this instant in time in any time zone you want using a DateFormat.
注意:Timestamp.valueOf("2010-10-23 12:05:16");
的意思是在默认时区中创建具有给定时间的时间戳".
Note: Timestamp.valueOf("2010-10-23 12:05:16");
means "create a timestamp with the given time in the default timezone".
这篇关于创建没有 timeZone 的时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!