{"id":7277,"date":"2024-11-14T12:56:14","date_gmt":"2024-11-14T04:56:14","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7277\/"},"modified":"2024-11-14T12:56:14","modified_gmt":"2024-11-14T04:56:14","slug":"springboot-%e4%b8%ad%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-mybatis-plus-%e6%9f%a5%e8%af%a2-mysql-date-%e5%ad%97%e6%ae%b5%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7277\/","title":{"rendered":"SpringBoot \u4e2d\u5982\u4f55\u4f7f\u7528 Mybatis-Plus \u67e5\u8be2 MySQL Date \u5b57\u6bb5\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173067931226865.jpg\" class=\"aligncenter\" title=\"SpringBoot \u4e2d\u5982\u4f55\u4f7f\u7528 Mybatis-Plus \u67e5\u8be2 MySQL Date \u5b57\u6bb5\uff1f\u63d2\u56fe\" alt=\"SpringBoot \u4e2d\u5982\u4f55\u4f7f\u7528 Mybatis-Plus \u67e5\u8be2 MySQL Date \u5b57\u6bb5\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>springboot \u5982\u4f55\u67e5\u8be2  date \u5b57\u6bb5<\/strong><\/p>\n<p>\u5728 spring boot \u9879\u76ee\u4e2d\uff0c\u5904\u7406\u65e5\u671f\u548c\u65f6\u95f4\u7c7b\u578b\u7684\u6570\u636e\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u6311\u6218\u3002\u672c\u95ee\u7b54\u65e8\u5728\u89e3\u51b3\u4ee5\u4e0b\u95ee\u9898\uff1a<\/p>\n<p><strong>\u95ee\u9898\uff1a<\/strong><\/p>\n<p>\u5982\u4f55\u5728 spring boot \u4e2d\u4f7f\u7528 mybatis-plus \u67e5\u8be2 mysql date \u5b57\u6bb5\uff0c\u800c\u907f\u514d\u9047\u5230\u7c7b\u578b\u8f6c\u6362\u95ee\u9898\uff1f<\/p>\n<p><strong>\u7b54\u6848\uff1a<\/strong><\/p>\n<p>\u901a\u5e38\uff0c\u540e\u7aef\u5efa\u8bae\u4f7f\u7528 string \u7c7b\u578b\u63a5\u6536\u65f6\u95f4\u6570\u636e\uff0c\u5373\u4f7f mysql \u5b57\u6bb5\u662f date \u6216 datetime \u7c7b\u578b\u3002\u8fd9\u6837\u505a\u53ef\u4ee5\u907f\u514d\u7c7b\u578b\u8f6c\u6362\u95ee\u9898\u3002\u5177\u4f53\u6765\u8bf4\uff0c\u5e94\u4f7f\u7528 @datetimeformat \u6ce8\u89e3\u6307\u5b9a\u671f\u671b\u7684\u524d\u7aef\u65e5\u671f\u683c\u5f0f\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>@DateTimeFormat(pattern = \"yyyy-MM-dd\")\n@ApiModelProperty(value = \"\u65e5\u671f\")\nprivate String lessonDate;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u6cd5\uff0c\u60a8\u53ef\u4ee5\u5728\u540e\u7aef\u76f4\u63a5\u4f7f\u7528 string \u7c7b\u578b\u8fdb\u884c\u67e5\u8be2\uff0c\u800c\u65e0\u9700\u8fdb\u884c\u7c7b\u578b\u8f6c\u6362\uff0c\u4ece\u800c\u907f\u514d\u6f5c\u5728\u7684\u9519\u8bef\u6216\u6570\u636e\u4e0d\u51c6\u786e\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fSpringBoot \u4e2d\u5982\u4f55\u4f7f\u7528 Mybatis-Plus \u67e5\u8be2 MySQL Date \u5b57\u6bb5\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>springboot \u5982\u4f55\u67e5\u8be2 date \u5b57\u6bb5 \u5728 spring boot \u9879\u76ee\u4e2d\uff0c\u5904\u7406\u65e5\u671f\u548c\u65f6\u95f4\u7c7b\u578b\u7684\u6570\u636e\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u6311\u6218\u3002\u672c\u95ee\u7b54\u65e8\u5728\u89e3\u51b3\u4ee5\u4e0b\u95ee\u9898\uff1a \u95ee\u9898\uff1a \u5982\u4f55\u5728 spring boot \u4e2d\u4f7f\u7528 mybatis-plus \u67e5\u8be2 mysql date \u5b57\u6bb5\uff0c\u800c\u907f\u514d\u9047\u5230\u7c7b\u578b\u8f6c\u6362\u95ee\u9898\uff1f \u7b54\u6848\uff1a \u901a\u5e38\uff0c\u540e\u7aef\u5efa\u8bae\u4f7f\u7528 string \u7c7b\u578b\u63a5\u6536\u65f6\u95f4\u6570\u636e\uff0c\u5373\u4f7f mysql \u5b57\u6bb5\u662f date \u6216 datetime \u7c7b\u578b\u3002\u8fd9\u6837\u505a\u53ef\u4ee5\u907f\u514d\u7c7b\u578b\u8f6c\u6362\u95ee\u9898\u3002\u5177\u4f53\u6765\u8bf4\uff0c\u5e94\u4f7f\u7528 @datetimeformat \u6ce8\u89e3\u6307\u5b9a\u671f\u671b\u7684\u524d\u7aef\u65e5\u671f\u683c\u5f0f\uff0c\u5982\u4e0b\u6240\u793a\uff1a @DateTimeFormat(pattern = &#8220;yyyy-MM-dd&#8221;) @ApiModelProperty(value = &#8220;\u65e5\u671f&#8221;) private String lessonDate; \u767b\u5f55\u540e\u590d\u5236 \u901a\u8fc7\u8fd9\u79cd\u65b9\u6cd5\uff0c\u60a8\u53ef\u4ee5\u5728\u540e\u7aef\u76f4\u63a5\u4f7f\u7528 string \u7c7b\u578b\u8fdb\u884c\u67e5\u8be2\uff0c\u800c\u65e0\u9700\u8fdb\u884c\u7c7b\u578b\u8f6c\u6362\uff0c\u4ece\u800c\u907f\u514d\u6f5c\u5728\u7684\u9519\u8bef\u6216\u6570\u636e\u4e0d\u51c6\u786e\u3002 \u4ee5\u4e0a\u5c31\u662fSpringBoot \u4e2d\u5982\u4f55\u4f7f\u7528 Mybatis-Plus \u67e5\u8be2 MySQL Date \u5b57\u6bb5\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-7277","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7277","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=7277"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7277\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}