Search code examples
javadatetimezonedstzoneddatetime

ZonedDateTime in Brazil still getting -2 instead of -3 offset


I'm working in a application that uses Java 8, Maven and Spring. Since 2019, the DayLight Saving Time was abolished in Brazil.

Basically I am changing all dates in the system to save in utc and be shown in the time zone of whoever is using the application. Most users are from Brazil

To fix the time zone problem I updated the JRE and JDK to the latest versions of java 8, and so all the dates that were indicating to be in summer time, started to return to normal time. With that I was able to convert the dates and I have been doing this for about two weeks

The problem is that today, around lunchtime, all the conversions I've been doing have suddenly returned to indicate daylight saving time, even without updating anything at all

Example:

calculatedList.forEach(dto -> {
    LocalDateTime date = dto.getResultDate();

    dto.setResultDate(date.atZone(ZoneId.of("UTC")).withZoneSameInstant(ZoneId.of("America/Sao_Paulo")).toLocalDateTime());
});

when I wrote this code, I made sure that the conversion took a date in utc and brought it to -3. Now this same method is converting to -2

I've been making codes like this for 2 weeks and everything has been working as it should until now. It's a very vague question, but I just can't imagine what I might have done to make the time zone go wrong. Can anyone help me understand what happened?


Solution

  • As per this page: https://www.oracle.com/technetwork/java/javase/tzdata-versions-138805.html

    Brazil no longer observes DST since:

    • 13.0.1
    • 11.0.5
    • 8u231
    • 7u241

    while your Java version is 1.8.0_221 which does not include that change.