Skip to content

How to set timezone for deserializeDatetime? #193

@gywndi

Description

@gywndi

Hi~

I make some little project with mysql-binlog-connector-java.

First all, I'm in Korea, and timezone is GMT+09:00.

mysql> show variables like '%time%zone';
+------------------+--------+
| Variable_name    | Value  |
+------------------+--------+
| system_time_zone | KST    |
| time_zone        | SYSTEM |
+------------------+--------+

mysql> select * from test;
+---+--------+---------------------+---------------------+
| i | d      | dt                  | ts                  |
+---+--------+---------------------+---------------------+
| 5 | abc    | 2017-12-20 18:01:24 | 2017-12-20 18:01:24 |
| 6 | abc    | 2017-12-20 18:01:24 | 2017-12-20 18:01:24 |
| 8 | abc    | 2017-12-20 18:58:45 | 2017-12-20 18:58:45 |
+---+--------+---------------------+---------------------+

I read the binlog event, but it shows wrong datetime information as below.

---------------------------------
dt : Thu Dec 21 01:01:24 KST 2017
ts : 2017-12-20 18:01:24.0
---------------------------------
dt : Thu Dec 21 01:01:24 KST 2017
ts : 2017-12-20 18:01:24.0
---------------------------------
dt : Thu Dec 21 01:58:45 KST 2017
ts : 2017-12-20 18:58:45.0

(1,'abc','2017-12-21 01:01:24','2017-12-20 18:01:24')
(2,'abc','2017-12-21 01:01:24','2017-12-20 18:01:24')
(3,'abc','2017-12-21 01:58:45','2017-12-20 18:58:45')

It seems that mysql loads into binlog on KST basis, while mysql-binlog-connector-java deserializes data on UTC basis. Therefore, +09:00 is eaten once more, and the wrong time seems to be recorded.

I think it is a simple solution to subtract 9 hours backwards ... but I do not think it is a proper solution. Is there any way to get data in KST instead of UTC according to user time zone setting?

Thanks.
Chan.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions