cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Problem with Time Zones

GBeltramini
3-Visitor

Problem with Time Zones

Hello All,

 

Last weekend Brazil should have entered Daylight Savings Time but it was canceled earlier this year by the government. After that, some services that use times are very strange.

 

For instance, this simple javascript code that returns the epoch timestamp:


time = new Date ("2019","09","25","0","0","0");
time_ms = time.valueOf();

result = time_ms;

 

This returns the following result: 1571968800000. 

Converting this epoch value to date time using https://www.epochconverter.com/ gives the following date-time: 

Thursday, October 24, 2019, 11:00:00 PM GMT-03:00 which is offset in 1 hour from the time inserted originally.

 

Using the same code on an online javascript editor such as https://playcode.io/ gives the result 1571972400000 which gives the correct date.

 

The time on the client-side and the server-side are correct. 

 

Any thoughts?

1 ACCEPTED SOLUTION

Accepted Solutions
Tudor
12-Amethyst
(To:GBeltramini)

ThingWorx has a number of libraries and dependencies that embed their own timezone database.  These timezone DBs can be out of date causing the issues with BRT time you outlined above. The BRT changes are included the the IANA 2019b and above timezone DBs: https://www.iana.org/time-zones

 

The upcoming patches for ThingWorx will attempt to update the third-party timezone libraries, but in the meantime the following two fixes are needed for your environment:

 

1. Update the JRE timezone database:

  1. Download the Oracle Timezone DB updater from: https://www.oracle.com/technetwork/java/javase/tzupdater-readme-136440.html
  2. On the ThingWorx server, run java -jar tzupdater.jar -V (this verifies the JRE timezone DB)
  3. Run java -jar tzupdater.jar -l (this will update the timezone DB to the latest version
  4. Run java -jar tzupdater.jar -V and validate the new version in 2019c

2. Update the Joda-time library deployed with ThingWorx:

  1. Stop the Tomcat server
  2. Download the joda-time-2.10.4.jar file from github: https://github.com/JodaOrg/joda-time/releases/tag/v2.10.4
  3. Navigate to Apache > webapps > Thingworx > WEB-INF > lib
  4. Delete the existing joda-time-2.9.4.jar file and add the downloaded joda-time-2.10.4.jar
  5. Restart Tomcat

Step #2 may need to be repeated if the ThingWorx.war file is re-deployed (i.e. you upgrade to a patch version that does not have the latest joda-time library, for example upgrading from 8.4.1 to 8.4.5 would require you to re-patch the joda-time jar file).

 

Please let me know if this addresses the issue or if you continue to see problems.

View solution in original post

3 REPLIES 3
Tudor
12-Amethyst
(To:GBeltramini)

ThingWorx has a number of libraries and dependencies that embed their own timezone database.  These timezone DBs can be out of date causing the issues with BRT time you outlined above. The BRT changes are included the the IANA 2019b and above timezone DBs: https://www.iana.org/time-zones

 

The upcoming patches for ThingWorx will attempt to update the third-party timezone libraries, but in the meantime the following two fixes are needed for your environment:

 

1. Update the JRE timezone database:

  1. Download the Oracle Timezone DB updater from: https://www.oracle.com/technetwork/java/javase/tzupdater-readme-136440.html
  2. On the ThingWorx server, run java -jar tzupdater.jar -V (this verifies the JRE timezone DB)
  3. Run java -jar tzupdater.jar -l (this will update the timezone DB to the latest version
  4. Run java -jar tzupdater.jar -V and validate the new version in 2019c

2. Update the Joda-time library deployed with ThingWorx:

  1. Stop the Tomcat server
  2. Download the joda-time-2.10.4.jar file from github: https://github.com/JodaOrg/joda-time/releases/tag/v2.10.4
  3. Navigate to Apache > webapps > Thingworx > WEB-INF > lib
  4. Delete the existing joda-time-2.9.4.jar file and add the downloaded joda-time-2.10.4.jar
  5. Restart Tomcat

Step #2 may need to be repeated if the ThingWorx.war file is re-deployed (i.e. you upgrade to a patch version that does not have the latest joda-time library, for example upgrading from 8.4.1 to 8.4.5 would require you to re-patch the joda-time jar file).

 

Please let me know if this addresses the issue or if you continue to see problems.

Hello @GBeltramini ,

 

JavaScript code that you write in ThingWorx services is compiled to Java bytecode and executed on JVM. The latter has its own timzone database, which is as old as the JDK you are using. Just random ideas (might be complete nonesense):

 

  1. Wait until a new version of JDK which supports your new tz;
  2. Try to update tz database in your JDK: https://www.oracle.com/technetwork/java/javase/documentation/tzupdater-readme-136440.html
  3. To make matters worse, ThingWorx uses Joda Time under the hood, which seems to have its own tz database, also updatable: https://www.joda.org/joda-time/tz_update.html
  4. You can specify tz explicitly for a time being. For example, this line of code returns 1571972400000, as you expect: parseDate("10/25/2019 00:00:00 -0300", "MM/dd/yyyy HH:mm:ss Z").getTime();

 

/ Constantine

slangley
23-Emerald II
(To:GBeltramini)

Hi @GBeltramini.

 

If one of the previous responses allowed you to resolve your issue, please mark the appropriate one as the Accepted Solution for the benefit of others with the same issue.

 

Regards.

 

--Sharon

Top Tags