23549

Java daylight saving seems to be wrong

Question:

I've been facing some issues with timezone with Java since yesterday (21/10/2018). Looks like java is considering that daylight saving have taken place in Brazil but it hasn't.

I created the following test to be sure

public static void main(String[] args) { ZonedDateTime dateTime = LocalDateTime.now().atZone(ZoneId.systemDefault()); System.out.println(dateTime); ZonedDateTime saoPaulo = dateTime.withZoneSameInstant(ZoneId.of("America/Sao_Paulo")); ZonedDateTime cuiba = dateTime.withZoneSameInstant(ZoneId.of("America/Cuiaba")); ZonedDateTime rightTime = dateTime.withZoneSameInstant(ZoneId.of("GMT-4")); System.out.println(saoPaulo); System.out.println(cuiba); System.out.println(rightTime); }

That gave the following output

2018-10-22T09:55:34.473-02:00[America/Sao_Paulo] 2018-10-22T09:55:34.473-02:00[America/Sao_Paulo] 2018-10-22T08:55:34.473-03:00[America/Cuiaba] 2018-10-22T07:55:34.473-04:00[GMT-04:00]

That's wrong as the current timezone to São Paulo should be -03 and America/Cuiaba should be -04

Anyone knows what's the source of the timezone information on Java? There is something I can do on my side to fix that? I know that I can fix it by setting a fixed GMT offset but I'm not fond of it.

Answer1:

The link posted by Jon Skeet helped me to solve my issue. Oracle had updated the daylight savings information on latest releases. After updating JDK version, it's working as expected.

2018-10-22T09:19:31.761-03:00[America/Sao_Paulo] 2018-10-22T09:19:31.761-03:00[America/Sao_Paulo] 2018-10-22T08:19:31.761-04:00[America/Cuiaba] 2018-10-22T08:19:31.761-04:00[GMT-04:00]

Recommend

  • edit link shifted after pressing search button in grid view C# win form
  • java.time.LocalDate to java.util.Date
  • Need to grep /etc/hosts with a known hostname, and then capture the ip address for the hostname from
  • unsupported Scan, storing driver.Value type []uint8 into type *time.Time
  • Convert java Calendar object from local time to UTC
  • How to control a script is not already running?
  • @TableGenerator not working with EclipseLink JPA 2.0
  • Error when uploading UWP app to Windows Store: Failed to merge PRI file \\Resources_split.scale-10
  • Query stays “statistics” state for long time in Google Cloud SQL (MySQL 5.5)
  • Fetching/Inserting huge chunks of data from/to a large table
  • Oracle sequence for a primary key field doesn't retrieve the currently inserted value in Hibern
  • Parse ISO8601 date string to date with UTC Timezone
  • File not found error for a QML file inside a Qt resource
  • “EEE MMM dd HH:mm:ss ZZZ yyyy” date format to java.sql.Date
  • Why can a 352GB NumPy ndarray be used on an 8GB memory macOS computer?
  • SQL standard for timestamp in UTC or with timezone
  • QML doesn't show svg images
  • how do you get window ID for xdotool automatically
  • anorm joda-time - localdatetime support
  • Confusion in java.Clock, systemDefaultZone() returning UTC time
  • Alarm Manager broadcasts unexpectedly
  • How to parse string with date, but without time in local format to ZonedDateTime?
  • How to perform join operation similar to SQL join in Azure DocumentDB
  • How can i write equivalent sql query with join?
  • How to Get DB Field name from ConstraintViolationException - Hibernamte
  • Hibernate CompositeUserType that is comparible in JPA-QL (or HQL) query
  • Mapping column types Slick 3.1.1
  • How to execute “sudo nvm”?
  • Specifying field size of Map collection in grails DOM
  • AngularJS ng-option get index
  • Spring Data JPA custom method causing PropertyReferenceException
  • Illegal mix of collations for operation for date/time comparison
  • Possible to stop flickering java tooltip in heavyweight mode?
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Proper folder structure for lots of source files
  • How does Linux kernel interrupt the application?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Checking variable from a different class in C#
  • How can I use threading to 'tick' a timer to be accessed by other threads?