mysql-connector-java 6.x 时区设置

  1. 云栖社区>
  2. 博客>
  3. 正文

mysql-connector-java 6.x 时区设置

科技小能手 2017-11-12 14:09:00 浏览970
展开阅读全文

    最近遇到了一个问题,java从mysql从读出的时间与本地时间有14个小时的时间差,经查证、测试解决了此问题,在此总结一下:


一、使用mysql-connector-java 6.x版本驱动需要做如下配置:

1、引入pom

1
2
3
4
5
<dependency>
  <groupId>mysql</groupId>
  <artifactId>mysql-connector-java</artifactId>
  <version>6.0.6</version>
</dependency>


2、设置jdbc连接、驱动

1
2
3
jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&serverTimezone=UTC&characterEncoding=utf-8&allowMultiQueries=true
 
com.mysql.cj.jdbc.Driver



二、设置mysql数据时区

1、查看mysql时区

1
show variables like "%time_zone%"

wKiom1nDVNGAzmOJAAANX4pyPzM345.png


2、修改mysql时区

(1)方法一

1
2
3
set global time_zone = '+8:00'; ##修改mysql全局时区为北京时间,即我们所在的东8区
set time_zone = '+8:00'; ##修改当前会话时区
flush privileges; #立即生效

(2)方法二、通过修改my.cnf配置文件来修改时区

1
2
3
# vim /etc/my.cnf ##在[mysqld]区域中加上
default-time_zone = '+8:00'
# /etc/init.d/mysqld restart ##重启mysql使新时区生效


三、分析时区设置问题

       通过上面的设置,我们把mysql数据库的时区设置成了中国的时区‘utc+8’,而serverTimezone=UTC设置的是utc时区,两者不同,所以会发现从数据库读出的时间与本地时间差几个小时。要解决这个问题,需要让serverTimezone的设置与数据库的时区保持一致。我们可以选择修改serverTimezone的设置为serverTimezone=Asia/Shanghai,或者修改数据库的时区为‘+0:00’。


四、serverTimezone支持的值说明

1、utc时区:serverTimezone=UTC

2、中国时区:serverTimezone=GMT%2B8(GMT+8这种方式支持全部时区,通过修改最后的数字实现,不过%2B不能写成+)

3、查看官方源码,可以看到serverTimezone支持的相关设置如下,如:中国的时区可设置为:serverTimezone=Asia/Shanghai

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
#Windows Zones
#Mon Sep 28 16:41:59 WEST 2015
AUS\ Central\ Daylight\ Time=Australia/Darwin
AUS\ Central\ Standard\ Time=Australia/Darwin
AUS\ Eastern\ Daylight\ Time=Australia/Sydney
AUS\ Eastern\ Standard\ Time=Australia/Sydney
Afghanistan\ Daylight\ Time=Asia/Kabul
Afghanistan\ Standard\ Time=Asia/Kabul
Alaskan\ Daylight\ Time=America/Anchorage
Alaskan\ Standard\ Time=America/Anchorage
Arab\ Daylight\ Time=Asia/Riyadh
Arab\ Standard\ Time=Asia/Riyadh
Arabian\ Daylight\ Time=Asia/Dubai
Arabian\ Standard\ Time=Asia/Dubai
Arabic\ Daylight\ Time=Asia/Baghdad
Arabic\ Standard\ Time=Asia/Baghdad
Argentina\ Daylight\ Time=America/Buenos_Aires
Argentina\ Standard\ Time=America/Buenos_Aires
Atlantic\ Daylight\ Time=America/Halifax
Atlantic\ Standard\ Time=America/Halifax
Azerbaijan\ Daylight\ Time=Asia/Baku
Azerbaijan\ Standard\ Time=Asia/Baku
Azores\ Daylight\ Time=Atlantic/Azores
Azores\ Standard\ Time=Atlantic/Azores
Bahia\ Daylight\ Time=America/Bahia
Bahia\ Standard\ Time=America/Bahia
Bangladesh\ Daylight\ Time=Asia/Dhaka
Bangladesh\ Standard\ Time=Asia/Dhaka
Belarus\ Daylight\ Time=Europe/Minsk
Belarus\ Standard\ Time=Europe/Minsk
Canada\ Central\ Daylight\ Time=America/Regina
Canada\ Central\ Standard\ Time=America/Regina
Cape\ Verde\ Daylight\ Time=Atlantic/Cape_Verde
Cape\ Verde\ Standard\ Time=Atlantic/Cape_Verde
Caucasus\ Daylight\ Time=Asia/Yerevan
Caucasus\ Standard\ Time=Asia/Yerevan
Cen.\ Australia\ Daylight\ Time=Australia/Adelaide
Cen.\ Australia\ Standard\ Time=Australia/Adelaide
Central\ America\ Daylight\ Time=America/Guatemala
Central\ America\ Standard\ Time=America/Guatemala
Central\ Asia\ Daylight\ Time=Asia/Almaty
Central\ Asia\ Standard\ Time=Asia/Almaty
Central\ Brazilian\ Daylight\ Time=America/Cuiaba
Central\ Brazilian\ Standard\ Time=America/Cuiaba
Central\ Daylight\ Time=America/Chicago
Central\ Daylight\ Time\ (Mexico)=America/Mexico_City
Central\ Europe\ Daylight\ Time=Europe/Budapest
Central\ Europe\ Standard\ Time=Europe/Budapest
Central\ European\ Daylight\ Time=Europe/Warsaw
Central\ European\ Standard\ Time=Europe/Warsaw
Central\ Pacific\ Daylight\ Time=Pacific/Guadalcanal
Central\ Pacific\ Standard\ Time=Pacific/Guadalcanal
Central\ Standard\ Time=America/Chicago
Central\ Standard\ Time\ (Mexico)=America/Mexico_City
China\ Daylight\ Time=Asia/Shanghai
China\ Standard\ Time=Asia/Shanghai
Dateline\ Daylight\ Time=Etc/GMT+12
Dateline\ Standard\ Time=Etc/GMT+12
E.\ Africa\ Daylight\ Time=Africa/Nairobi
E.\ Africa\ Standard\ Time=Africa/Nairobi
E.\ Australia\ Daylight\ Time=Australia/Brisbane
E.\ Australia\ Standard\ Time=Australia/Brisbane
E.\ South\ America\ Daylight\ Time=America/Sao_Paulo
E.\ South\ America\ Standard\ Time=America/Sao_Paulo
Eastern\ Daylight\ Time=America/New_York
Eastern\ Daylight\ Time\ (Mexico)=America/Cancun
Eastern\ Standard\ Time=America/New_York
Eastern\ Standard\ Time\ (Mexico)=America/Cancun
Egypt\ Daylight\ Time=Africa/Cairo
Egypt\ Standard\ Time=Africa/Cairo
Ekaterinburg\ Daylight\ Time=Asia/Yekaterinburg
Ekaterinburg\ Standard\ Time=Asia/Yekaterinburg
FLE\ Daylight\ Time=Europe/Kiev
FLE\ Standard\ Time=Europe/Kiev
Fiji\ Daylight\ Time=Pacific/Fiji
Fiji\ Standard\ Time=Pacific/Fiji
GMT\ Daylight\ Time=Europe/London
GMT\ Standard\ Time=Europe/London
GTB\ Daylight\ Time=Europe/Bucharest
GTB\ Standard\ Time=Europe/Bucharest
Georgian\ Daylight\ Time=Asia/Tbilisi
Georgian\ Standard\ Time=Asia/Tbilisi
Greenland\ Daylight\ Time=America/Godthab
Greenland\ Standard\ Time=America/Godthab
Greenwich\ Daylight\ Time=Atlantic/Reykjavik
Greenwich\ Standard\ Time=Atlantic/Reykjavik
Hawaiian\ Daylight\ Time=Pacific/Honolulu
Hawaiian\ Standard\ Time=Pacific/Honolulu
India\ Daylight\ Time=Asia/Calcutta
India\ Standard\ Time=Asia/Calcutta
Iran\ Daylight\ Time=Asia/Tehran
Iran\ Standard\ Time=Asia/Tehran
Israel\ Daylight\ Time=Asia/Jerusalem
Israel\ Standard\ Time=Asia/Jerusalem
Jordan\ Daylight\ Time=Asia/Amman
Jordan\ Standard\ Time=Asia/Amman
Kaliningrad\ Daylight\ Time=Europe/Kaliningrad
Kaliningrad\ Standard\ Time=Europe/Kaliningrad
Korea\ Daylight\ Time=Asia/Seoul
Korea\ Standard\ Time=Asia/Seoul
Libya\ Daylight\ Time=Africa/Tripoli
Libya\ Standard\ Time=Africa/Tripoli
Line\ Islands\ Daylight\ Time=Pacific/Kiritimati
Line\ Islands\ Standard\ Time=Pacific/Kiritimati
Magadan\ Daylight\ Time=Asia/Magadan
Magadan\ Standard\ Time=Asia/Magadan
Mauritius\ Daylight\ Time=Indian/Mauritius
Mauritius\ Standard\ Time=Indian/Mauritius
Middle\ East\ Daylight\ Time=Asia/Beirut
Middle\ East\ Standard\ Time=Asia/Beirut
Montevideo\ Daylight\ Time=America/Montevideo
Montevideo\ Standard\ Time=America/Montevideo
Morocco\ Daylight\ Time=Africa/Casablanca
Morocco\ Standard\ Time=Africa/Casablanca
Mountain\ Daylight\ Time=America/Denver
Mountain\ Daylight\ Time\ (Mexico)=America/Chihuahua
Mountain\ Standard\ Time=America/Denver
Mountain\ Standard\ Time\ (Mexico)=America/Chihuahua
Myanmar\ Daylight\ Time=Asia/Rangoon
Myanmar\ Standard\ Time=Asia/Rangoon
N.\ Central\ Asia\ Daylight\ Time=Asia/Novosibirsk
N.\ Central\ Asia\ Standard\ Time=Asia/Novosibirsk
Namibia\ Daylight\ Time=Africa/Windhoek
Namibia\ Standard\ Time=Africa/Windhoek
Nepal\ Daylight\ Time=Asia/Katmandu
Nepal\ Standard\ Time=Asia/Katmandu
New\ Zealand\ Daylight\ Time=Pacific/Auckland
New\ Zealand\ Standard\ Time=Pacific/Auckland
Newfoundland\ Daylight\ Time=America/St_Johns
Newfoundland\ Standard\ Time=America/St_Johns
North\ Asia\ Daylight\ Time=Asia/Krasnoyarsk
North\ Asia\ East\ Daylight\ Time=Asia/Irkutsk
North\ Asia\ East\ Standard\ Time=Asia/Irkutsk
North\ Asia\ Standard\ Time=Asia/Krasnoyarsk
Pacific\ Daylight\ Time=America/Los_Angeles
Pacific\ Daylight\ Time\ (Mexico)=America/Santa_Isabel
Pacific\ SA\ Daylight\ Time=America/Santiago
Pacific\ SA\ Standard\ Time=America/Santiago
Pacific\ Standard\ Time=America/Los_Angeles
Pacific\ Standard\ Time\ (Mexico)=America/Santa_Isabel
Pakistan\ Daylight\ Time=Asia/Karachi
Pakistan\ Standard\ Time=Asia/Karachi
Paraguay\ Daylight\ Time=America/Asuncion
Paraguay\ Standard\ Time=America/Asuncion
Romance\ Daylight\ Time=Europe/Paris
Romance\ Standard\ Time=Europe/Paris
Russia\ Time\ Zone\ 10=Asia/Srednekolymsk
Russia\ Time\ Zone\ 11=Asia/Kamchatka
Russia\ Time\ Zone\ 3=Europe/Samara
Russian\ Daylight\ Time=Europe/Moscow
Russian\ Standard\ Time=Europe/Moscow
SA\ Eastern\ Daylight\ Time=America/Cayenne
SA\ Eastern\ Standard\ Time=America/Cayenne
SA\ Pacific\ Daylight\ Time=America/Bogota
SA\ Pacific\ Standard\ Time=America/Bogota
SA\ Western\ Daylight\ Time=America/La_Paz
SA\ Western\ Standard\ Time=America/La_Paz
SE\ Asia\ Daylight\ Time=Asia/Bangkok
SE\ Asia\ Standard\ Time=Asia/Bangkok
Samoa\ Daylight\ Time=Pacific/Apia
Samoa\ Standard\ Time=Pacific/Apia
Singapore\ Daylight\ Time=Asia/Singapore
Singapore\ Standard\ Time=Asia/Singapore
South\ Africa\ Daylight\ Time=Africa/Johannesburg
South\ Africa\ Standard\ Time=Africa/Johannesburg
Sri\ Lanka\ Daylight\ Time=Asia/Colombo
Sri\ Lanka\ Standard\ Time=Asia/Colombo
Syria\ Daylight\ Time=Asia/Damascus
Syria\ Standard\ Time=Asia/Damascus
Taipei\ Daylight\ Time=Asia/Taipei
Taipei\ Standard\ Time=Asia/Taipei
Tasmania\ Daylight\ Time=Australia/Hobart
Tasmania\ Standard\ Time=Australia/Hobart
Tokyo\ Daylight\ Time=Asia/Tokyo
Tokyo\ Standard\ Time=Asia/Tokyo
Tonga\ Daylight\ Time=Pacific/Tongatapu
Tonga\ Standard\ Time=Pacific/Tongatapu
Turkey\ Daylight\ Time=Europe/Istanbul
Turkey\ Standard\ Time=Europe/Istanbul
US\ Eastern\ Daylight\ Time=America/Indianapolis
US\ Eastern\ Standard\ Time=America/Indianapolis
US\ Mountain\ Daylight\ Time=America/Phoenix
US\ Mountain\ Standard\ Time=America/Phoenix
UTC=Etc/GMT
UTC+12=Etc/GMT-12
UTC-02=Etc/GMT+2
UTC-11=Etc/GMT+11
Ulaanbaatar\ Daylight\ Time=Asia/Ulaanbaatar
Ulaanbaatar\ Standard\ Time=Asia/Ulaanbaatar
Venezuela\ Daylight\ Time=America/Caracas
Venezuela\ Standard\ Time=America/Caracas
Vladivostok\ Daylight\ Time=Asia/Vladivostok
Vladivostok\ Standard\ Time=Asia/Vladivostok
W.\ Australia\ Daylight\ Time=Australia/Perth
W.\ Australia\ Standard\ Time=Australia/Perth
W.\ Central\ Africa\ Daylight\ Time=Africa/Lagos
W.\ Central\ Africa\ Standard\ Time=Africa/Lagos
W.\ Europe\ Daylight\ Time=Europe/Berlin
W.\ Europe\ Standard\ Time=Europe/Berlin
West\ Asia\ Daylight\ Time=Asia/Tashkent
West\ Asia\ Standard\ Time=Asia/Tashkent
West\ Pacific\ Daylight\ Time=Pacific/Port_Moresby
West\ Pacific\ Standard\ Time=Pacific/Port_Moresby
Yakutsk\ Daylight\ Time=Asia/Yakutsk
Yakutsk\ Standard\ Time=Asia/Yakutsk
#Linked Time Zones alias
#Mon Sep 28 16:41:59 WEST 2015
Africa/Addis_Ababa=Africa/Nairobi
Africa/Asmara=Africa/Nairobi
Africa/Asmera=Africa/Nairobi
Africa/Bamako=Africa/Abidjan
Africa/Bangui=Africa/Lagos
Africa/Banjul=Africa/Abidjan
Africa/Blantyre=Africa/Maputo
Africa/Brazzaville=Africa/Lagos
Africa/Bujumbura=Africa/Maputo
Africa/Conakry=Africa/Abidjan
Africa/Dakar=Africa/Abidjan
Africa/Dar_es_Salaam=Africa/Nairobi
Africa/Djibouti=Africa/Nairobi
Africa/Douala=Africa/Lagos
Africa/Freetown=Africa/Abidjan
Africa/Gaborone=Africa/Maputo
Africa/Harare=Africa/Maputo
Africa/Juba=Africa/Khartoum
Africa/Kampala=Africa/Nairobi
Africa/Kigali=Africa/Maputo
Africa/Kinshasa=Africa/Lagos
Africa/Libreville=Africa/Lagos
Africa/Lome=Africa/Abidjan
Africa/Luanda=Africa/Lagos
Africa/Lubumbashi=Africa/Maputo
Africa/Lusaka=Africa/Maputo
Africa/Malabo=Africa/Lagos
Africa/Maseru=Africa/Johannesburg
Africa/Mbabane=Africa/Johannesburg
Africa/Mogadishu=Africa/Nairobi
Africa/Niamey=Africa/Lagos
Africa/Nouakchott=Africa/Abidjan
Africa/Ouagadougou=Africa/Abidjan
Africa/Porto-Novo=Africa/Lagos
Africa/Sao_Tome=Africa/Abidjan
Africa/Timbuktu=Africa/Abidjan
America/Anguilla=America/Port_of_Spain
America/Antigua=America/Port_of_Spain
America/Argentina/ComodRivadavia=America/Argentina/Catamarca
America/Aruba=America/Curacao
America/Atka=America/Adak
America/Buenos_Aires=America/Argentina/Buenos_Aires
America/Catamarca=America/Argentina/Catamarca
America/Coral_Harbour=America/Atikokan
America/Cordoba=America/Argentina/Cordoba
America/Dominica=America/Port_of_Spain
America/Ensenada=America/Tijuana
America/Fort_Wayne=America/Indiana/Indianapolis
America/Grenada=America/Port_of_Spain
America/Guadeloupe=America/Port_of_Spain
America/Indianapolis=America/Indiana/Indianapolis
America/Jujuy=America/Argentina/Jujuy
America/Knox_IN=America/Indiana/Knox
America/Kralendijk=America/Curacao
America/Louisville=America/Kentucky/Louisville
America/Lower_Princes=America/Curacao
America/Marigot=America/Port_of_Spain
America/Mendoza=America/Argentina/Mendoza
America/Montreal=America/Toronto
America/Montserrat=America/Port_of_Spain
America/Porto_Acre=America/Rio_Branco
America/Rosario=America/Argentina/Cordoba
America/Shiprock=America/Denver
America/St_Barthelemy=America/Port_of_Spain
America/St_Kitts=America/Port_of_Spain
America/St_Lucia=America/Port_of_Spain
America/St_Thomas=America/Port_of_Spain
America/St_Vincent=America/Port_of_Spain
America/Tortola=America/Port_of_Spain
America/Virgin=America/Port_of_Spain
Antarctica/McMurdo=Pacific/Auckland
Antarctica/South_Pole=Pacific/Auckland
Arctic/Longyearbyen=Europe/Oslo
Asia/Aden=Asia/Riyadh
Asia/Ashkhabad=Asia/Ashgabat
Asia/Bahrain=Asia/Qatar
Asia/Calcutta=Asia/Kolkata
Asia/Chongqing=Asia/Shanghai
Asia/Chungking=Asia/Shanghai
Asia/Dacca=Asia/Dhaka
Asia/Harbin=Asia/Shanghai
Asia/Istanbul=Europe/Istanbul
Asia/Kashgar=Asia/Urumqi
Asia/Katmandu=Asia/Kathmandu
Asia/Kuwait=Asia/Riyadh
Asia/Macao=Asia/Macau
Asia/Muscat=Asia/Dubai
Asia/Phnom_Penh=Asia/Bangkok
Asia/Saigon=Asia/Ho_Chi_Minh
Asia/Tel_Aviv=Asia/Jerusalem
Asia/Thimbu=Asia/Thimphu
Asia/Ujung_Pandang=Asia/Makassar
Asia/Ulan_Bator=Asia/Ulaanbaatar
Asia/Vientiane=Asia/Bangkok
Atlantic/Faeroe=Atlantic/Faroe
Atlantic/Jan_Mayen=Europe/Oslo
Atlantic/St_Helena=Africa/Abidjan
Australia/ACT=Australia/Sydney
Australia/Canberra=Australia/Sydney
Australia/LHI=Australia/Lord_Howe
Australia/NSW=Australia/Sydney
Australia/North=Australia/Darwin
Australia/Queensland=Australia/Brisbane
Australia/South=Australia/Adelaide
Australia/Tasmania=Australia/Hobart
Australia/Victoria=Australia/Melbourne
Australia/West=Australia/Perth
Australia/Yancowinna=Australia/Broken_Hill
Brazil/Acre=America/Rio_Branco
Brazil/DeNoronha=America/Noronha
Brazil/East=America/Sao_Paulo
Brazil/West=America/Manaus
Canada/Atlantic=America/Halifax
Canada/Central=America/Winnipeg
Canada/East-Saskatchewan=America/Regina
Canada/Eastern=America/Toronto
Canada/Mountain=America/Edmonton
Canada/Newfoundland=America/St_Johns
Canada/Pacific=America/Vancouver
Canada/Saskatchewan=America/Regina
Canada/Yukon=America/Whitehorse
Chile/Continental=America/Santiago
Chile/EasterIsland=Pacific/Easter
Cuba=America/Havana
Egypt=Africa/Cairo
Eire=Europe/Dublin
Europe/Belfast=Europe/London
Europe/Bratislava=Europe/Prague
Europe/Busingen=Europe/Zurich
Europe/Guernsey=Europe/London
Europe/Isle_of_Man=Europe/London
Europe/Jersey=Europe/London
Europe/Ljubljana=Europe/Belgrade
Europe/Mariehamn=Europe/Helsinki
Europe/Nicosia=Asia/Nicosia
Europe/Podgorica=Europe/Belgrade
Europe/San_Marino=Europe/Rome
Europe/Sarajevo=Europe/Belgrade
Europe/Skopje=Europe/Belgrade
Europe/Tiraspol=Europe/Chisinau
Europe/Vaduz=Europe/Zurich
Europe/Vatican=Europe/Rome
Europe/Zagreb=Europe/Belgrade
GB=Europe/London
GB-Eire=Europe/London
GMT+0=Etc/GMT
GMT-0=Etc/GMT
GMT0=Etc/GMT
Greenwich=Etc/GMT
Hongkong=Asia/Hong_Kong
Iceland=Atlantic/Reykjavik
Indian/Antananarivo=Africa/Nairobi
Indian/Comoro=Africa/Nairobi
Indian/Mayotte=Africa/Nairobi
Iran=Asia/Tehran
Israel=Asia/Jerusalem
Jamaica=America/Jamaica
Japan=Asia/Tokyo
Kwajalein=Pacific/Kwajalein
Libya=Africa/Tripoli
Mexico/BajaNorte=America/Tijuana
Mexico/BajaSur=America/Mazatlan
Mexico/General=America/Mexico_City
NZ=Pacific/Auckland
NZ-CHAT=Pacific/Chatham
Navajo=America/Denver
PRC=Asia/Shanghai
Pacific/Johnston=Pacific/Honolulu
Pacific/Midway=Pacific/Pago_Pago
Pacific/Ponape=Pacific/Pohnpei
Pacific/Saipan=Pacific/Guam
Pacific/Samoa=Pacific/Pago_Pago
Pacific/Truk=Pacific/Chuuk
Pacific/Yap=Pacific/Chuuk
Poland=Europe/Warsaw
Portugal=Europe/Lisbon
ROC=Asia/Taipei
ROK=Asia/Seoul
Singapore=Asia/Singapore
Turkey=Europe/Istanbul
UCT=Etc/UCT
US/Alaska=America/Anchorage
US/Aleutian=America/Adak
US/Arizona=America/Phoenix
US/Central=America/Chicago
US/East-Indiana=America/Indiana/Indianapolis
US/Eastern=America/New_York
US/Hawaii=Pacific/Honolulu
US/Indiana-Starke=America/Indiana/Knox
US/Michigan=America/Detroit
US/Mountain=America/Denver
US/Pacific=America/Los_Angeles
US/Pacific-New=America/Los_Angeles
US/Samoa=Pacific/Pago_Pago
Universal=Etc/UTC
W-SU=Europe/Moscow
Zulu=Etc/UTC
#Standard (IANA) abbreviations
#Mon Sep 28 16:41:59 WEST 2015
ACWST=Australia/Eucla
AFT=Asia/Kabul
ALMT=Asia/Almaty
ANAT=Asia/Anadyr
AZOST=Atlantic/Azores
AZOT=Atlantic/Azores
AZST=Asia/Baku
AZT=Asia/Baku
BDT=Asia/Dhaka
BNT=Asia/Brunei
BOT=America/La_Paz
BRST=America/Sao_Paulo
BTT=Asia/Thimphu
CAT=Africa/Maputo
CCT=Indian/Cocos
CHADT=Pacific/Chatham
CHAST=Pacific/Chatham
CHOST=Asia/Choibalsan
CHOT=Asia/Choibalsan
CHUT=Pacific/Chuuk
CKT=Pacific/Rarotonga
COT=America/Bogota
CVT=Atlantic/Cape_Verde
CXT=Indian/Christmas
ChST=Pacific/Guam
DAVT=Antarctica/Davis
DDUT=Antarctica/DumontDUrville
EAST=Pacific/Easter
ECT=America/Guayaquil
EGST=America/Scoresbysund
EGT=America/Scoresbysund
FJST=Pacific/Fiji
FJT=Pacific/Fiji
FKST=Atlantic/Stanley
FNT=America/Noronha
GALT=Pacific/Galapagos
GAMT=Pacific/Gambier
GET=Asia/Tbilisi
GFT=America/Cayenne
GILT=Pacific/Tarawa
GYT=America/Guyana
HDT=America/Adak
HKT=Asia/Hong_Kong
HOVST=Asia/Hovd
HOVT=Asia/Hovd
IDT=Asia/Jerusalem
IOT=Indian/Chagos
IRST=Asia/Tehran
JST=Asia/Tokyo
KGT=Asia/Bishkek
KOST=Pacific/Kosrae
LHDT=Australia/Lord_Howe
LHST=Australia/Lord_Howe
LINT=Pacific/Kiritimati
MAGT=Asia/Magadan
MART=Pacific/Marquesas
MAWT=Antarctica/Mawson
MEST=MET
MET=MET
MIST=Antarctica/Macquarie
MMT=Asia/Rangoon
MUT=Indian/Mauritius
MVT=Indian/Maldives
NCT=Pacific/Noumea
NDT=America/St_Johns
NFT=Pacific/Norfolk
NOVT=Asia/Novosibirsk
NPT=Asia/Kathmandu
NRT=Pacific/Nauru
NST=America/St_Johns
NUT=Pacific/Niue
NZDT=Pacific/Auckland
NZST=Pacific/Auckland
OMST=Asia/Omsk
ORAT=Asia/Oral
PET=America/Lima
PETT=Asia/Kamchatka
PGT=Pacific/Port_Moresby
PHOT=Pacific/Enderbury
PHT=Asia/Manila
PKT=Asia/Karachi
PMDT=America/Miquelon
PMST=America/Miquelon
PONT=Pacific/Pohnpei
PWT=Pacific/Palau
PYST=America/Asuncion
PYT=America/Asuncion
QYZT=Asia/Qyzylorda
RET=Indian/Reunion
ROTT=Antarctica/Rothera
SAKT=Asia/Sakhalin
SAMT=Europe/Samara
SAST=Africa/Johannesburg
SBT=Pacific/Guadalcanal
SCT=Indian/Mahe
SGT=Asia/Singapore
SRET=Asia/Srednekolymsk
SRT=America/Paramaribo
SST=Pacific/Pago_Pago
SYOT=Antarctica/Syowa
TAHT=Pacific/Tahiti
TFT=Indian/Kerguelen
TJT=Asia/Dushanbe
TKT=Pacific/Fakaofo
TLT=Asia/Dili
TMT=Asia/Ashgabat
TOT=Pacific/Tongatapu
TVT=Pacific/Funafuti
ULAST=Asia/Ulaanbaatar
ULAT=Asia/Ulaanbaatar
UYT=America/Montevideo
VET=America/Caracas
VOST=Antarctica/Vostok
VUT=Pacific/Efate
WAKT=Pacific/Wake
WAST=Africa/Windhoek
WFT=Pacific/Wallis
WGST=America/Godthab
WGT=America/Godthab
WIT=Asia/Jayapura
WITA=Asia/Makassar
WSDT=Pacific/Apia
WSST=Pacific/Apia
XJT=Asia/Urumqi
YEKT=Asia/Yekaterinburg

以上内容在src\main\resources\com\mysql\cj\jdbc\util.TimeZoneMapping.properties,

= 后面的值为我们可以用来设置的值



 本文转自 独孤环宇 51CTO博客,原文链接:http://blog.51cto.com/snowtiger/1967441



网友评论

登录后评论
0/500
评论
科技小能手
+ 关注