{"id":2160,"date":"2020-09-24T18:54:22","date_gmt":"2020-09-24T10:54:22","guid":{"rendered":"https:\/\/nj.transwarp.cn:8180\/?p=2160"},"modified":"2024-06-25T14:16:10","modified_gmt":"2024-06-25T06:16:10","slug":"%e5%a6%82%e4%bd%95%e9%81%bf%e5%85%8d%e5%a4%8f%e4%bb%a4%e6%97%b6%ef%bc%88dst%ef%bc%89%e5%af%b9date%e7%b1%bb%e5%9e%8b%e6%95%b0%e6%8d%ae%e7%9a%84%e5%bd%b1%e5%93%8d","status":"publish","type":"post","link":"https:\/\/kbwp.transwarp.cn\/?p=2160","title":{"rendered":"\u5982\u4f55\u907f\u514d\u590f\u4ee4\u65f6\uff08DST\uff09\u5bf9Date\u7c7b\u578b\u6570\u636e\u7684\u5f71\u54cd"},"content":{"rendered":"<h3>\u6982\u8981\u63cf\u8ff0<\/h3>\n<hr \/>\n<p><strong>\u590f\u65f6\u4ee4\uff08Daylight Saving Time\uff1aDST\uff09\uff0c\u53c8\u79f0\u201c\u65e5\u5149\u8282\u7ea6\u65f6\u5236\u201d\u548c\u201c\u590f\u4ee4\u65f6\u95f4\u201d\uff0c\u662f\u4e00\u79cd\u4e3a\u8282\u7ea6\u80fd\u6e90\u800c\u4eba\u4e3a\u89c4\u5b9a\u5730\u65b9\u65f6\u95f4\u7684\u5236\u5ea6\uff0c\u5728\u8fd9\u4e00\u5236\u5ea6\u5b9e\u884c\u671f\u95f4\u6240\u91c7\u7528\u7684\u7edf\u4e00\u65f6\u95f4\u79f0\u4e3a\u201c\u590f\u4ee4\u65f6\u95f4\u201d\u3002\u5404\u5730\u5b9e\u884c\u590f\u4ee4\u65f6\u7684\u65f6\u95f4\u4e0d\u4e00\u81f4\uff0c\u5177\u4f53\u505a\u6cd5\u662f\u4f1a\u5728\u7ea6\u5b9a\u7684\u65f6\u95f4\u5c06\u65f6\u949f\u62e8\u5feb\u4e00\u5c0f\u65f6\u3002<\/strong><\/p>\n<h3>\u8be6\u7ec6\u8bf4\u660e<\/h3>\n<hr \/>\n<ul>\n<li>\u73af\u5883\u51c6\u5907\uff1aTDH6.2.1<\/li>\n<\/ul>\n<h3>\u73b0\u8c61\u63cf\u8ff0<\/h3>\n<hr \/>\n<h4>1. \u57fa\u7840\u67e5\u8be2\u5f02\u5e38<\/h4>\n<ul>\n<li>\u7531\u4e8e\u590f\u4ee4\u65f6(1)\u7684\u539f\u56e0\uff0cDate\u7c7b\u578b\u7684\u6570\u636e\u6709\u53ef\u80fd\u51fa\u73b0\u81ea\u52a8\u8865\u4e00\u5c0f\u65f6\u7684\u60c5\u51b5<\/li>\n<\/ul>\n<pre><code class=\"language-sql\">0: jdbc:hive2:\/\/172.22.23.6:10000> select cast('19910414' as date) from system.dual;\n+----------------------+\n|         _c0          |\n+----------------------+\n| 1991-04-14 01:00:00  |\n+----------------------+\n1 row selected (0.141 seconds)\n<\/code><\/pre>\n<h4>2. torc\u8868\u4e2d\u7684date\u7c7b\u578b\u6570\u636e\u5f02\u5e38<\/h4>\n<pre><code class=\"language-sql\">0: jdbc:hive2:\/\/172.22.23.6:10000> create table t_orc(id int, birth_date date) CLUSTERED BY (id) INTO 2 BUCKETS stored as orc TBLPROPERTIES('transactional'='true');\nNo rows affected (0.315 seconds)\n0: jdbc:hive2:\/\/172.22.23.6:10000> insert into t_orc select 8,'1991-04-14 12:12:12' from system.dual;\n1 row affected (1.322 seconds)\n0: jdbc:hive2:\/\/172.22.23.6:10000> select * from t_orc;\n+-----+----------------------+\n| id  |      birth_date      |\n+-----+----------------------+\n| 8   | 1991-04-14 01:00:00  |\n+-----+----------------------+\n1 row selected (0.58 seconds)\n<\/code><\/pre>\n<h4>3. \u65e5\u671f\u8ba1\u7b97\u51fd\u6570\u7ed3\u679c\u5f02\u5e38<\/h4>\n<pre><code class=\"language-sql\">0: jdbc:hive2:\/\/172.22.23.6:10000> select datediff(TDH_TODATE('19910419'),TDH_TODATE('19910414')) from system.dual;\n+------+\n| _c0  |\n+------+\n| 4    |\n+------+\n1 row selected (0.129 seconds)<\/code><\/pre>\n<h3>\u6545\u969c\u539f\u56e0<\/h3>\n<hr \/>\n<p>\u6211\u4eec\u7cfb\u7edf\u7684date\uff08HiveDate\uff09\u7c7b\u578b\u89c4\u5b9a\u5f53\u65f6\u95f4\u90e8\u5206\u4e3a\u96f6\u7684\u65f6\u5019\uff0c\u8f93\u51fa\u4e0d\u5e26\u6709\u65f6\u95f4\u90e8\u5206\uff0c\u5982\u679c\u65f6\u95f4\u90e8\u5206\u4e0d\u4e3a\u96f6\u5219\u8f93\u51fa\u5e26\u6709\u65f6\u95f4\u90e8\u5206\u3002<\/p>\n<p>torc\u8868\u5728\u5904\u7406\u65e5\u671f\u7c7b\u578b\u7684\u7684\u65f6\u5019\u53ea\u5b58\u65e5\u671f\u90e8\u5206\uff0c\u5c06\u65f6\u95f4\u90e8\u5206\u76f4\u63a5\u820d\u53bb\u3002\u6240\u4ee5\u5bf9\u4e8e\u65e5\u671f\uff1a&#8217;1991-04-14 12:12:12&#8217;\uff0c\u5c31\u53ea\u4fdd\u7559\u65e5\u671f\u90e8\u5206\uff0c\u7cfb\u7edf\u4e2d\u4f1a\u5c06\u8be5\u65e5\u671f\u8bc6\u522b\u4e3a&#8217;1991-04-14&#8242;,\u4f46\u662f\u7531\u4e8e\u590f\u4ee4\u65f6\u7684\u5f71\u54cd\uff0c\u4f1a\u76f4\u63a5\u52a0\u4e0a\u4e00\u4e2a\u5c0f\u65f6\u7684\u504f\u79fb\u91cf\uff0c\u4f7f\u5f97\u65e5\u671f\u7684\u65f6\u95f4\u90e8\u5206\u4e0d\u4e3a0\uff0c\u8fd9\u6837\u65f6\u95f4\u90e8\u5206\u5c31\u4f1a\u88ab\u8f93\u51fa\u3002\u5f53\u7136\u672c\u6765\u5c31\u4e0d\u5e26\u6709\u65f6\u95f4\u90e8\u5206\u7684\u65e5\u671f\u503c\u4e5f\u4f1a\u56e0\u4e3a\u590f\u4ee4\u65f6\u88ab\u52a0\u4e0a\u4e00\u4e2a\u5c0f\u65f6\u7684\u504f\u79fb\u91cf\u8f93\u51fa\u3002<\/p>\n<h4>\u67e5\u8be2\u590f\u4ee4\u65f6\u7684\u65b9\u6cd5<\/h4>\n<h5>1. linux\u67e5\u770b\u7cfb\u7edf\u65f6\u533a<\/h5>\n<pre><code class=\"language-shell\">[root@kevin001 ~]# ll \/etc\/localtime\nlrwxrwxrwx. 1 root root 35 4\u6708  29 2019 \/etc\/localtime -> ..\/usr\/share\/zoneinfo\/Asia\/Shanghai<\/code><\/pre>\n<h5>2. \u6bcf\u4e2a\u56fd\u5bb6\u5b9e\u73b0\u7684\u590f\u4ee4\u65f6\u7684\u89c4\u5219\u4e0d\u540c\uff0c\u5177\u4f53\u590f\u4ee4\u65f6\u65f6\u95f4\u9700\u8981\u67e5\u770blocaltime\u6587\u4ef6<\/h5>\n<h5>3. \u67e5\u770b\u6240\u6709\u5b9e\u73b0\u590f\u4ee4\u65f6\u7684\u65f6\u95f4<\/h5>\n<p><strong>\u672c\u5730\u65f6\u533a\uff1a<\/strong><\/p>\n<pre><code class=\"language-shell\">[root@kevin001 ~]# zdump -v \/etc\/localtime | grep isdst=1\n\/etc\/localtime  Sun Jun  2 16:00:00 1940 UTC = Mon Jun  3 01:00:00 1940 CDT isdst=1 gmtoff=32400\n\/etc\/localtime  Mon Sep 30 14:59:59 1940 UTC = Mon Sep 30 23:59:59 1940 CDT isdst=1 gmtoff=32400\n\/etc\/localtime  Sat Mar 15 16:00:00 1941 UTC = Sun Mar 16 01:00:00 1941 CDT isdst=1 gmtoff=32400\n\/etc\/localtime  Tue Sep 30 14:59:59 1941 UTC = Tue Sep 30 23:59:59 1941 CDT isdst=1 gmtoff=32400\n\/etc\/localtime  Sat May  3 16:00:00 1986 UTC = Sun May  4 01:00:00 1986 CDT isdst=1 gmtoff=32400\n\/etc\/localtime  Sat Sep 13 14:59:59 1986 UTC = Sat Sep 13 23:59:59 1986 CDT isdst=1 gmtoff=32400\n\/etc\/localtime  Sat Apr 11 16:00:00 1987 UTC = Sun Apr 12 01:00:00 1987 CDT isdst=1 gmtoff=32400\n\/etc\/localtime  Sat Sep 12 14:59:59 1987 UTC = Sat Sep 12 23:59:59 1987 CDT isdst=1 gmtoff=32400\n\/etc\/localtime  Sat Apr  9 16:00:00 1988 UTC = Sun Apr 10 01:00:00 1988 CDT isdst=1 gmtoff=32400\n\/etc\/localtime  Sat Sep 10 14:59:59 1988 UTC = Sat Sep 10 23:59:59 1988 CDT isdst=1 gmtoff=32400\n\/etc\/localtime  Sat Apr 15 16:00:00 1989 UTC = Sun Apr 16 01:00:00 1989 CDT isdst=1 gmtoff=32400\n\/etc\/localtime  Sat Sep 16 14:59:59 1989 UTC = Sat Sep 16 23:59:59 1989 CDT isdst=1 gmtoff=32400\n\/etc\/localtime  Sat Apr 14 16:00:00 1990 UTC = Sun Apr 15 01:00:00 1990 CDT isdst=1 gmtoff=32400\n\/etc\/localtime  Sat Sep 15 14:59:59 1990 UTC = Sat Sep 15 23:59:59 1990 CDT isdst=1 gmtoff=32400\n\/etc\/localtime  Sat Apr 13 16:00:00 1991 UTC = Sun Apr 14 01:00:00 1991 CDT isdst=1 gmtoff=32400\n\/etc\/localtime  Sat Sep 14 14:59:59 1991 UTC = Sat Sep 14 23:59:59 1991 CDT isdst=1 gmtoff=32400<\/code><\/pre>\n<p><strong>\u67d0\u4e2a\u6307\u5b9a\u65f6\u533a\uff1a<\/strong><\/p>\n<pre><code class=\"language-shell\">[root@kevin001 ~]# zdump -v \/usr\/share\/zoneinfo\/Australia\/ACT | grep isdst=1 \n<\/code><\/pre>\n<h3>\u89e3\u51b3\u529e\u6cd5<\/h3>\n<hr \/>\n<h4>\u89e3\u51b3\u65b9\u6848\u4e00\uff1a\u4fee\u6539jvm\u542f\u52a8\u53c2\u6570<\/h4>\n<p>\u7740\u91cd\u8bf4\u660e\u4e0b\uff1a<\/p>\n<p><strong><font color=red>1\uff09\u4fee\u6539\u5bbf\u4e3b\u673a\u7684\u65f6\u533a\u3001\u65e0\u6cd5\u5f71\u54cd\u670d\u52a1pod\u5185\u7684\u65f6\u533a\uff0c\u5373\u4fee\u6539\u5bbf\u4e3b\u673a\u7684\u65f6\u533a\u5e76\u4e14\u91cd\u542f\u5e73\u53f0\u670d\u52a1\u540e\u3001pod\u5185\u7684\u65f6\u533a\u5e76\u4e0d\u4f1a\u968f\u4e4b\u6539\u53d8\uff1b<\/font><\/strong><br \/>\n<strong><font color=red>2\uff09\u4fee\u6539\u670d\u52a1pod\u7684\u65f6\u533a\u3001\u3010\u6709\u53ef\u80fd\u3011\u5bf9pod\u5185java\u8fdb\u7a0b\u7684jvm\u65f6\u533a\u5e76\u4e0d\u751f\u6548\uff0c\u5373\u4fee\u6539\u955c\u50cf\u7684\u65f6\u533a\u5e76\u4e14\u91cd\u542f\u5e73\u53f0\u670d\u52a1\u540e\u3001pod\u5185java\u8fdb\u7a0b\u7684jvm\u65f6\u533a\u5e76\u4e0d\u4f1a\u968f\u4e4b\u6539\u53d8\u3002<\/font><\/strong><\/p>\n<p>\u6570\u636e\u7684\u6d41\u8f6c\u662f\u5728jvm\u4e2d\u8fdb\u884c\u7684\uff0c\u56e0\u6b64\u6211\u4eec\u5fc5\u987b\u6709\u6548\u5730\u4fee\u6b63\u76f8\u5173\u670d\u52a1\u7684java\u8fdb\u7a0bjvm\u65f6\u533a\u4e3aEtc\/GMT-8\uff0c \u624d\u80fd\u89e3\u51b3\u590f\u4ee4\u65f6\u7684\u95ee\u9898\u3002<\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7manager\u4e0a\u670d\u52a1\u7684config\u754c\u9762\u4fee\u6539\uff0c<code>EXTRA_DRIVER_OPTS<\/code>\u3001<code>EXTRA_EXECUTOR_OPTS<\/code>\u3001<code>EXTRA_METASTORE_OPTS<\/code>\u6dfb\u52a0\u914d\u7f6e<code>-Duser.timezone=Etc\/GMT-8<\/code>\uff0c\u7136\u540e\u914d\u7f6e\u91cd\u542f\u670d\u52a1\u5373\u53ef\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/nj.transwarp.cn:8180\/wp-content\/uploads\/2020\/09\/image-1719296118130.png\" alt=\"file\" \/><\/p>\n<p>\u91cd\u542f\u670d\u52a1\u540e\uff0c\u901a\u8fc7\u547d\u4ee4<code>sudo -u hive jcmd &lt;pid&gt; VM.system_properties | grep timezone<\/code>\u67e5\u770b\u8fdb\u7a0b\u7684jvm\u65f6\u533a\uff0c\u4ee5quark server\u4e3a\u4f8b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/nj.transwarp.cn:8180\/wp-content\/uploads\/2020\/09\/image-1719296194153.png\" alt=\"file\" \/><\/p>\n<h4>\u89e3\u51b3\u65b9\u6848\u4e8c\uff1a\u4f7f\u7528string\u7c7b\u578b\u66ff\u4ee3Date\u7c7b\u578b<\/h4>\n<p>\u5982\u679c\u5e76\u975e\u575a\u51b3\u8981\u7528Date\u7c7b\u578b\u6765\u88c5\u6570\u636e\uff0c\u53ef\u4ee5\u4f7f\u7528string\u7c7b\u578b\u6765\u5b58\u653e\u65e5\u671f\u6570\u636e\uff0c\u4f7f\u7528string\u5c31\u4e0d\u4f1a\u51fa\u73b0\u4e0a\u8ff0\u7684\u95ee\u9898\u3002<\/p>\n<h3>\u7ed3\u679c\u9a8c\u8bc1<\/h3>\n<hr \/>\n<h4>1. \u57fa\u7840\u67e5\u8be2\u6b63\u5e38<\/h4>\n<pre><code class=\"language-sql\">0: jdbc:hive2:\/\/172.22.23.6:10000> select cast('19910414' as date) from system.dual;\n+-------------+\n|     _c0     |\n+-------------+\n| 1991-04-14  |\n+-------------+\n1 row selected (0.165 seconds)<\/code><\/pre>\n<h4>2. torc\u8868\u4e2d\u7684date\u7c7b\u578b\u6570\u636e\u6b63\u5e38<\/h4>\n<pre><code class=\"language-sql\">0: jdbc:hive2:\/\/172.22.23.6:10000> select * from t_orc;\n+-----+-------------+\n| id  | birth_date  |\n+-----+-------------+\n| 8   | 1991-04-14  |\n+-----+-------------+\n1 row selected (0.601 seconds)<\/code><\/pre>\n<h4>3. \u65e5\u671f\u8ba1\u7b97\u51fd\u6570\u7ed3\u679c\u6b63\u5e38<\/h4>\n<pre><code class=\"language-sql\">0: jdbc:hive2:\/\/172.22.23.6:10000>  select datediff(TDH_TODATE('19910419'),TDH_TODATE('19910414')) from system.dual;\n+------+\n| _c0  |\n+------+\n| 5    |\n+------+\n1 row selected (0.191 seconds)\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981\u63cf\u8ff0 \u590f\u65f6\u4ee4\uff08Daylight Saving Time\uff1aDST\uff09\uff0c\u53c8\u79f0\u201c\u65e5\u5149\u8282\u7ea6\u65f6\u5236\u201d\u548c\u201c\u590f\u4ee4\u65f6\u95f4\u201d\uff0c\u662f\u4e00 ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/kbwp.transwarp.cn\/?p=2160\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40],"tags":[],"class_list":["post-2160","post","type-post","status-publish","format-standard","hentry","category-sql_issue"],"acf":[],"_links":{"self":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/2160","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2160"}],"version-history":[{"count":5,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/2160\/revisions"}],"predecessor-version":[{"id":13455,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/2160\/revisions\/13455"}],"wp:attachment":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}