gpt4 book ai didi

java - Timestamp.valueOf() 根据 JVM 版本返回不同的值

转载 作者:IT老高 更新时间:2023-10-28 20:53:23 25 4
gpt4 key购买 nike

Timestamp sTs = Timestamp.valueOf("1900-12-31 23:59:59.999"); // Make Timestamp
System.out.println("sTs====>" + sTs.getTime());

sTs====> -2177485200001 // in jdk 1.4


Timestamp sTs = Timestamp.valueOf("1900-12-31 23:59:59.999"); // Make Timestamp
System.out.println("sTs====>" + sTs.getTime());

sTs====> -2177483400001 // in jdk 1.5

为什么这两个值不同?

最佳答案

根据 Sun 网站上现已删除的帖子

Daylight Saving Time (DST) is a system of handling the changing amounts of daylight throughout the year. The goal of DST is to maximize the daylight hours available during typical waking hours. By adjusting clocks ahead a standard amount, usually an hour, people can have more daylight available during their typical work day. For example, suppose you wake daily at 7:00 AM. In the spring, the sun rises earlier each day. Instead of waking up at 6:00 AM to take advantage of the daylight, DST observers move their clocks ahead an hour. The effect is that they can continue to wake at 7:00 AM according to the clock and enjoy more daylight. In the fall, people set their clocks back an hour as sunrise happens later each day.

The United States has planned a change to its DST observance beginning in 2007. The Energy Policy Act of 2005 mandates that DST will start on the second Sunday in March and end on the first Sunday in November. In 2007, the start and stop dates will be March 11 and November 4, respectively. These dates are different from previous DST start and stop dates. In 2006, the dates were the first Sunday in April (April 2, 2006) and the last Sunday in October (October 29, 2006).

The Java Runtime Environment (JRE) stores rules about DST observance all around the globe. Older JREs will have outdated rules that will be superseded by the Energy Policy Act of 2005. As a result, applications running on an older JRE may report incorrect time from March 11, 2007 through April 2, 2007 and from October 29, 2007 through November 4, 200

此更改已在 Java 1.4.2_13 中更新。因此,如果您的版本较旧,那么您会看到不同的行为。

关于java - Timestamp.valueOf() 根据 JVM 版本返回不同的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23778107/

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