problem with daylight saving time and java applications on ubuntu server 16.04

2

This weekend we had the switch to DST here in my area, I have some machines running ubuntu server 16.04 with java applications.

All of them with JBOSS , POSTGRES for one application and one with GLASSFISH , MYSQL .

If I type the command #date on the server it returns me the correct date, already set for daylight saving time, but at the time of saving the records in the applications they get the wrong date!

For example: Now it is 12:45 if I save any record in any of the applications it writes as 11:45 .

I think it's a problem with java, has anyone had it? or do you know how to solve it?

I use OPEN JDK 1.7.0_95

    
asked by anonymous 18.10.2017 / 16:49

2 answers

2

I just went through this same problem, mainly because daylight saving time in 2018 was extended until November 4 because of the elections. Java uses its own database to know the spindles and the beginning and end of DST, in this case, just update it using the # from Oracle itself. The problem is just what you described, you type date in the terminal and the date comes correct, however, if you instantiate a date in java and print the time information, it comes with an hour less.

After downloading tzupdater.jar, just run it as follows:

java -jar tzupdater.jar -l

Remembering that this command requires elevation (sudo) because it will update the JRE files.

In JDK 7 the command worked smoothly.

In JDK 8, you returned the error java.lang.Exception: Failed while parsing file '/tmp/tz.tmp_1/asia'

In this case, you need to edit the file and put it back in the tar.gz that it downloads to update. I made a shell script in this other post that makes the necessary fix on the file and then installs it.

I hope I have helped

    
23.10.2018 / 02:10
2

I went through the same problem and solved with the following:

sudo java -jar tzupdater.jar  -l https://data.iana.org/time-zones/releases/tzdata2018e.tar.gz
  • Then restart the java application and check the date.

In addition, I created a playbook to update the JVM of containers.

    
29.10.2018 / 13:22