Why when year is less than 1884, it remove few milliseconds?

后端 未结 2 1464
醉梦人生
醉梦人生 2020-12-06 17:43
DateTime start = new DateTime().withYear(1884);
System.out.println(start);
System.out.println(start.minusYears(1));

Output

1884-01-         


        
相关标签:
2条回答
  • 2020-12-06 17:45

    The standard time has been adopted by the US during this year.

    1883: U.S. and Canadian railways adopt five standardized time zones to replace the multiplicity of local times in communities across the continent. Everyone would soon be operating on "railroad time."

    Source

    Wikipedia page about Standard Time

    0 讨论(0)
  • 2020-12-06 17:46

    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
    
    0 讨论(0)
提交回复
热议问题