I made an APP that can check the date of the specified date, but tonight someone suddenly found that the date of the day does not correspond to the date. (March 26, 2021 is the date of the year, but the software shows jia Xu date.) I thought it was the algorithm at first, but when I tested it, the algorithm worked. Then I thought it was the time zone, so I set it to east 8. It didn’t work. I wonder why there were no bugs when I sent it to others last year. We have to sacrifice the date printing algorithm. I was shocked by the results, and here’s the log I printed:
I/ system. out: a day is counted if the remainder is greater than 0. 3823113943000 343000.0 I/System. Out: dry 1616767284000-2206346659000 I/System. Out: I/System. Out: I/System. Out: I/System. Dry branch 2021-03-26 22:01:24 1900-01-31 22:01:24Copy the code
The date and time stamp on the back obviously don’t match. Then I called getTimezoneOffset() and found that it was 485 and 480. Boy, that was a good five minutes. I thought Google was taking aim at me by messing with 1912. After some testing, the time difference began to change to 480 on January 1, 1901. It seems that the period before 1901 is problematic.
Finally, I changed the basis of time, chose the National Day as the basis for the calculation of dry day, to commemorate our great republic.