Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

DateTime start = new DateTime().withYear(1884);
System.out.println(start);
System.out.println(start.minusYears(1));

Output

1884-01-11T08:26:10.234-08:00
1883-01-11T08:26:10.234-07:52:58

Edit 1: I was not correct. It did not removed 1.02 sec

DateTime start = new DateTime().withYear(1884);
DateTime other = start.minusYears(1);
long diffMs = start.getMillis() - other.getMillis(); //31536422000

Edit 2:

Interesting, I was confused by the output for toString(); - (-08:00, -07:52:58)

Edit 3:

With Java Calendar, I don't see any differences:

Calendar cal = Calendar.getInstance();
cal.set(start.getYear(), 
        start.getMonthOfYear(), 
        start.getDayOfMonth(), 
        start.getHourOfDay(), 
        start.getMinuteOfHour(), 
        start.getSecondOfDay());
System.out.println(cal.getTime());

cal = Calendar.getInstance();
cal.set(start.getYear()- 1, 
        start.getMonthOfYear(), 
        start.getDayOfMonth(), 
        start.getHourOfDay(), 
        start.getMinuteOfHour(), 
        start.getSecondOfDay());
System.out.println(cal.getTime());

Output:

Mon Feb 11 18:46:42 PST 1884
Sun Feb 11 18:46:42 PST 1883
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
160 views
Welcome To Ask or Share your Answers For Others

1 Answer

From this time zone history page;

Four standard time zones for the continental United States were introduced on November 18, 1883. Britain, which already adopted its own standard time system for England, Scotland, and Wales, helped gather international consensus for global time zones in 1884.

In other words, the US time zones changed between those two timestamps.

EDIT: If you have your time zone set to PST (the time zone), you will not see this effect, while if you have it set to a location (for example America/Los_Angeles), you will. This due to that the time zone offset of PST didn't change, instead PST was created and Los Angeles changed from LMT to PST) That is, Los Angeles time changed, while PST didn't.

As a demo, you can try this on linux;

# PST test
$ TZ=PST8PDT date -d '1883-01-01 12:00:00 UTC'
Mon Jan  1 04:00:00 PST 1883

# America/Los_Angeles test
$ TZ=America/Los_Angeles date -d '1883-01-01 12:00:00 UTC'
Mon Jan  1 04:07:02 LMT 1883

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...