@@ -25,16 +25,18 @@ public MySQLTimeZoneComparison(Connection connection)
25
25
this .connection = connection ;
26
26
}
27
27
28
- public void compareTimeZone () throws SQLException
28
+ public void compareTimeZone ()
29
+ throws SQLException
29
30
{
30
31
TimeZone serverTimeZone = null ;
31
32
try {
32
33
serverTimeZone = getServerTimeZone ();
33
- } catch (SQLException ex ) {
34
- logger .error (String .format (Locale .ENGLISH ,"SQLException raised %s" ,ex .toString ()));
34
+ }
35
+ catch (SQLException ex ) {
36
+ logger .error (String .format (Locale .ENGLISH , "SQLException raised %s" , ex .toString ()));
35
37
}
36
38
37
- if ( serverTimeZone == null ) {
39
+ if ( serverTimeZone == null ) {
38
40
logger .warn ("Can't get server TimeZone." );
39
41
return ;
40
42
}
@@ -43,8 +45,8 @@ public void compareTimeZone() throws SQLException
43
45
Date today = new Date ();
44
46
int clientOffset = clientTimeZone .getRawOffset ();
45
47
46
- if ( clientTimeZone .inDaylightTime (today ) ) {
47
- clientOffset += clientTimeZone .getDSTSavings ();
48
+ if ( clientTimeZone .inDaylightTime (today )) {
49
+ clientOffset += clientTimeZone .getDSTSavings ();
48
50
}
49
51
50
52
//
@@ -54,21 +56,20 @@ public void compareTimeZone() throws SQLException
54
56
// TimeZone tz_gmt9 = TimeZone.getTimeZone("GMT+9");
55
57
// tz_jst.hasSameRules(tz_gmt9) // return false.
56
58
//
57
- if ( clientOffset != serverTimeZone .getRawOffset () ) {
59
+ if ( clientOffset != serverTimeZone .getRawOffset ()) {
58
60
logger .warn (String .format (Locale .ENGLISH ,
59
61
"The client timezone(%s) is different from the server timezone(%s). The plugin will fetch wrong datetime values." ,
60
- clientTimeZone .getID (),serverTimeZone .getID ()));
62
+ clientTimeZone .getID (), serverTimeZone .getID ()));
61
63
logger .warn (String .format (Locale .ENGLISH ,
62
64
"Use You may need to set options `useLegacyDatetimeCode` and `serverTimeZone`" ));
63
65
logger .warn (String .format (Locale .ENGLISH ,
64
66
"Ex. `options: { useLegacyDatetimeCode: false, serverTimeZone: UTC }`" ));
65
67
}
66
- logger .warn (String .format (Locale .ENGLISH ,"The plugin will set `useLegacyDatetimeCode=false` by default in future." ));
67
-
68
-
68
+ logger .warn (String .format (Locale .ENGLISH , "The plugin will set `useLegacyDatetimeCode=false` by default in future." ));
69
69
}
70
70
71
- private TimeZone getServerTimeZone () throws SQLException
71
+ private TimeZone getServerTimeZone ()
72
+ throws SQLException
72
73
{
73
74
//
74
75
// First, I used `@@system_time_zone`. but It return non Time Zone Abbreviations name on a specific platform.
@@ -86,15 +87,15 @@ private TimeZone getServerTimeZone() throws SQLException
86
87
else {
87
88
return null ;
88
89
}
89
-
90
- } finally {
90
+ }
91
+ finally {
91
92
stmt .close ();
92
93
}
93
94
}
94
95
95
96
private TimeZone fromGMTOffsetSeconds (int offsetSeconds )
96
97
{
97
- if ( offsetSeconds == 0 ) {
98
+ if ( offsetSeconds == 0 ) {
98
99
return TimeZone .getTimeZone ("UTC" );
99
100
}
100
101
0 commit comments