Re: The time zone CST has different meanings on MySQL Server and on conntector/j
Posted by: Filipe Silva
Date: May 23, 2017 05:09PM

Please never rely on time zone abbreviations on your production systems. They are not standard, accurate neither deterministic.

The support Connector/J provides for such cases is the best effort in finding a time zone that best fits the needs for most of the users. As such, if some time zone abbreviation is recognized in Java internals, Connector/J takes that for granted and uses it.

Mind that CST is known to mean "Central Standard Time", "China Standard Time", "Cuba Standard Time", and perhaps even more. There is no way of knowing exactly what each user expects.

Note that, up to date, MySQL does not support time zone identifiers in temporal data types.

Having that in mind, what you should do is to set the connection property 'serverTimezone=Asia/Shanghai' in your connection string and set the same time zone in your MySQL server (https://dev.mysql.com/doc/refman/5.7/en/time-zone-support.html). This is the only way of always getting the expected results from Connector/J and MySQL. Actually it is generally recommended to use a non-DST aware time zone in the server (such as UTC-0) in order to avoid discrepancies caused by the DST gaps and overlaps, but in the end it's up to you. "China Standard Time" is currently non-DST aware but nothing prevents this to change in the future, and it seems it has been so in the past, as such, those old rules may still affect you.

I hope that helps.

Options: ReplyQuote


Subject
Written By
Posted
Re: The time zone CST has different meanings on MySQL Server and on conntector/j
May 23, 2017 05:09PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.