Your JVM should still have the old daylight saving rules. Until 2017, Brazilian summer time began on the third Sunday of October, but in December # and from 2018, the start will be on the first Sunday of November.
p>
As these settings stay in the JVM, it still thinks that daylight saving time will start on October 21, 2018. Proof of this is "BRST" , which is the abbreviation for "Brasilia Summer Time" (another name for Brazilian summer time).
To fix, you must update the JVM time zone information. There are 2 ways to do it:
Update the Java version. On this page you can see that versions 10, 8u172, 7u181 and 6u191 have the tzdata2018c , which is the version that has the new Brazilian DST rules (see the fourth column: "Brazil's DST will now start on November's first Sunday" ). Just update Java to one of these versions.
Only update the JVM tzdata (the time zone information) without changing the Java version. To do so, you'll need to run the TZ Updater Tool . One of the arguments of this command is the file you are going to use, and the file can be found at link
Currently the latest file is the link , you can download it and run the command as instructed . But always check the IANA site for a more recent file.
My JVM has already been updated, so the output of your code to me is:
Sun Oct 21 00:00:00 BRT 2018
Note that it is no longer "BRST", but "BRT", indicating that it is not in daylight saving time.
Without updating the time zone information, it is not possible to set the time for midnight on the 21st, because of the way daylight saving time works.
When daylight saving time begins, the following happens: by the time midnight arrives, the clock is automatically advanced by one hour. We literally "skipped" an hour: every minute between 00:00 and 00:59 does not exist on this day.
Computers and cell phones now have these settings and automatically change. The clock jumps from 23:59 straight to 01:00. So, when daylight saving time starts, there is no midnight, and the API adjusts for the next valid time (in this case, 1:00 AM).
And since your JVM still has the old rules, it thinks that daylight saving time starts on October 21, so it is not possible to set the time for midnight on this day.
Detail: After updating the JVM, the problem of day 21 will be corrected. However, this situation will still occur on November 4, when daylight saving time begins.