[JAVA] About the daylight saving time that really happened

Merry Christmas. Since it is better to have many cases of trouble, I would like to share the phenomenon that "this happened in an in-house inquiry!".

Content of inquiry

In our system, if you register master data about a person, the information necessary for creating data for accounting system and tax system will be automatically linked without re-entering. At one point, I received an inquiry that "the data registered in the master and the data linked to the tax data will be off by one day." When I investigated it with the idea that "it's just linked, but it doesn't shift", it turned out that the phenomenon occurred only in a specific year ... From this point, "that? Will be.

What day did it occur?

The registration date of the master who inquired It was May 11, 1951. If only that data is linked, it will be May 10, 1951. However, if you create the data for December 1, 1951, it will be linked correctly as it is. What happened on this day? When I looked it up ...

Daylight saving time that was also in Japan

The cause was during daylight saving time.

Daylight saving time is to shift the clock time by one hour during a specific period and live based on that. For example, a person who goes to work at 9 am and returns at 6 pm will actually go to work at 10 am and return at 19:00. Then, when the summer time is over, set the hands of the clock back by one hour.

It seems that the policy is to make effective use of bright hours, but this was a problem.

Time conversion

When handling date information in Java, our system used to get the date + time. From the database registered on May 11, 1951 in question, convert to the Christian era, 1951-5-11 00:00 (Japan time) And timed data is generated.

In Java, this is during daylight saving time, so it is internally set back by one hour. Then, when you get it 1951-5-10 23:00 (Japan time) This means that if you use only the date for display, you will go back one day.

I didn't notice it ...

Daylight saving time

Information around here http://d.hatena.ne.jp/nowokay/20130917 There are also details on this page, so please refer to it if you want to know more in detail.

By the way, the period corresponding to daylight saving time in Japan is as follows. May 3rd (Monday) -September 11th (Saturday), 1948 April 4th (Monday) -September 10th (Saturday), 1945 May 8th (Monday) -September 9th (Saturday), 1950 May 7th (Monday) -September 8th (Saturday), 1951

Various measures have been implemented in Japan in the past ... I learned about this matter including the background.

Recommended Posts

About the daylight saving time that really happened
Daylight saving time problem also in Japan
The story that docker had a hard time
A story about making a Builder that inherits the Builder
About the method
About the package
It's about time to face the parenthesized monster (JavaScript)
About the matter that hidden_field can be used insanely