gpt4 book ai didi

Java new Date() 当前时间错误

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:50:11 25 4
gpt4 key购买 nike

当我这样做时:

new Date();

年、日和其他东西都可以,但小时和分钟是错误的。我在我的计算机上使用 64 位 Windows 7 并且:

Windows time is OK,
Bios Time is OK,
Windows Time Zone is OK,
Windows Time Zone at Regedit is OK

但是,当我在 Java(我使用 Java 1.6)上检查日期对象时,区域信息的 id 是 America/Caracas,应该是 Europe/Istanbul

可能是什么问题,有什么想法吗?

PS:我不想将时区作为 VM 参数传递,我不想使用日历对象因为我有一些库使用 Date 对象而不是任何东西,我只是想学习这个问题

最佳答案

我觉得这个blog可以帮助你。

引用博文解决问题:

After opening the date/time dialog from the Windows XP Control Panel, and applying one of following changes, Java API starts working correcty:

  • Changing date/time manually and then changing back to original correct time.
  • Changing timezone and then back to original one.
  • Requesting automatic time update from time server.

对于记录和来自同一个博客:

Some further investigation revealed that:

  • People complain about wrong timezone issues on Sun Java Virtual Machine since JRE 1.3. Several bug reports were submitted against Sun Java Virtual Machine during last ten years about wrong default timezone.
  • Nearly all reports were rejected by Sun as unreproducible.

关于Java new Date() 当前时间错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14502885/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com