Insert UTC timestamp into MySQL

I have a Java client that is inserting (through a CSV and 'LOAD DATA INFILE') timestamps (type TIMESTAMP) in UTC format in a MySQL DB. My server's timezone is "America/New_York" and I need to keep daylight savings information. November 5th at 2:00am is when the time changes from EDT to EST and clocks are set back one hour to 1:00AM. So November 5th 1:30 AM, for instance, happens twice; once in EDT and once in EST.

How can I make the server distinguish between the two? For instance, if I want to insert '2017-11-05 01:30:00' EDT, is there a way to tell MySQL to tell the difference between '2017-11-05 01:30:00' EDT (before the time change) and '2017-11-05 01:30:00' EST (after the time change) when I insert values? My Java application has the timezone information of both timestamps if that matters.

I want to keep the server's global timezone as 'America/New_York' because users access this data and want it displayed in their local time.

The solution I thought of is to set the connection's timezone to UTC from the Java client, insert the values in UTC and then reset the connection's timezone back, but I wanted to know if there was a better, more 'standard' solution.


使用jodaTime API与newYork或东部时区http://joda-time.sourceforge.net/timezones.html为什么这个乔达抵消不能获得日照权

链接地址: http://www.djcxy.com/p/29386.html

上一篇: 如何在夏令时期间使用TimeZoneInfo获取当地时间?

下一篇: 将UTC时间戳插入到MySQL中