{"id":7280,"date":"2024-11-14T12:22:03","date_gmt":"2024-11-14T04:22:03","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7280\/"},"modified":"2024-11-14T12:22:03","modified_gmt":"2024-11-14T04:22:03","slug":"springboot-%e4%b8%ad%e6%9f%a5%e8%af%a2-mysql-date-%e5%ad%97%e6%ae%b5%e7%9a%84%e6%ad%a3%e7%a1%ae%e5%a7%bf%e5%8a%bf%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7280\/","title":{"rendered":"SpringBoot \u4e2d\u67e5\u8be2 MySQL Date \u5b57\u6bb5\u7684\u6b63\u786e\u59ff\u52bf\u662f\u4ec0\u4e48\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173067992974746.jpg\" class=\"aligncenter\" title=\"SpringBoot \u4e2d\u67e5\u8be2 MySQL Date \u5b57\u6bb5\u7684\u6b63\u786e\u59ff\u52bf\u662f\u4ec0\u4e48\uff1f\u63d2\u56fe\" alt=\"SpringBoot \u4e2d\u67e5\u8be2 MySQL Date \u5b57\u6bb5\u7684\u6b63\u786e\u59ff\u52bf\u662f\u4ec0\u4e48\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>springboot \u67e5\u8be2  date \u5b57\u6bb5\u7684\u6b63\u786e\u59ff\u52bf<\/strong><\/p>\n<p>\u5728 springboot \u4e2d\u67e5\u8be2 mysql \u7684 date \u5b57\u6bb5\u65f6\uff0c\u5e38\u4f1a\u9047\u5230\u65e5\u671f\u7c7b\u578b\u4e0d\u5339\u914d\u7684\u95ee\u9898\uff0c\u5bfc\u81f4\u67e5\u8be2\u7ed3\u679c\u4e0d\u6b63\u786e\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u4eec\u901a\u5e38\u91c7\u7528\u4ee5\u4e0b\u505a\u6cd5\uff1a<\/p>\n<p>\u5728\u524d\u7aef\u5c06\u65e5\u671f\u683c\u5f0f\u5316\u4e3a &#8220;yy-mm-dd&#8221; \u5b57\u7b26\u4e32\uff0c\u901a\u8fc7 post \u8bf7\u6c42\u63d0\u4ea4\u3002<\/p>\n<pre>@datetimeformat(pattern = \"yyyy-mm-dd\")\nprivate string lessondate;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728\u540e\u7aef\u4f7f\u7528 string \u7c7b\u578b\u63a5\u6536\u65e5\u671f\u53c2\u6570\u3002<\/p>\n<pre>@requestparam(value = \"lessondate\") string lessondate;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728 mybatis-plus \u67e5\u8be2\u65f6\uff0c\u4f7f\u7528 ${} \u8fde\u63a5\u7b26\u5c06\u5b57\u7b26\u4e32\u53c2\u6570\u8f6c\u6362\u4e3a date \u7c7b\u578b\u3002<\/p>\n<pre>&lt;select id=\"selectByDate\" resultType=\"java.util.Map\"&gt;\n  SELECT * FROM table_name WHERE lessonDate = ${lessonDate}\n&lt;\/select&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u540e\u7aef\u63a5\u6536\u5230\u7684\u65e5\u671f\u53c2\u6570\u59cb\u7ec8\u4e3a\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u5728\u67e5\u8be2\u65f6\u518d\u8f6c\u6362\u4e3a date \u7c7b\u578b\uff0c\u4e0e mysql \u7684 date \u5b57\u6bb5\u4fdd\u6301\u4e00\u81f4\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fSpringBoot \u4e2d\u67e5\u8be2 MySQL Date \u5b57\u6bb5\u7684\u6b63\u786e\u59ff\u52bf\u662f\u4ec0\u4e48\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 \u67e5\u8be2 date \u5b57\u6bb5\u7684\u6b63\u786e\u59ff\u52bf \u5728 springboot \u4e2d\u67e5\u8be2 mysql \u7684 date \u5b57\u6bb5\u65f6\uff0c\u5e38\u4f1a\u9047\u5230\u65e5\u671f\u7c7b\u578b\u4e0d\u5339\u914d\u7684\u95ee\u9898\uff0c\u5bfc\u81f4\u67e5\u8be2\u7ed3\u679c\u4e0d\u6b63\u786e\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u4eec\u901a\u5e38\u91c7\u7528\u4ee5\u4e0b\u505a\u6cd5\uff1a \u5728\u524d\u7aef\u5c06\u65e5\u671f\u683c\u5f0f\u5316\u4e3a &#8220;yy-mm-dd&#8221; \u5b57\u7b26\u4e32\uff0c\u901a\u8fc7 post \u8bf7\u6c42\u63d0\u4ea4\u3002 @datetimeformat(pattern = &#8220;yyyy-mm-dd&#8221;) private string lessondate; \u767b\u5f55\u540e\u590d\u5236 \u5728\u540e\u7aef\u4f7f\u7528 string \u7c7b\u578b\u63a5\u6536\u65e5\u671f\u53c2\u6570\u3002 @requestparam(value = &#8220;lessondate&#8221;) string lessondate; \u767b\u5f55\u540e\u590d\u5236 \u5728 mybatis-plus \u67e5\u8be2\u65f6\uff0c\u4f7f\u7528 ${} \u8fde\u63a5\u7b26\u5c06\u5b57\u7b26\u4e32\u53c2\u6570\u8f6c\u6362\u4e3a date \u7c7b\u578b\u3002 &lt;select id=&#8221;selectByDate&#8221; resultType=&#8221;java.util.Map&#8221;&gt; SELECT * FROM table_name WHERE lessonDate = ${lessonDate} &lt;\/select&gt; \u767b\u5f55\u540e\u590d\u5236 \u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u540e\u7aef\u63a5\u6536\u5230\u7684\u65e5\u671f\u53c2\u6570\u59cb\u7ec8\u4e3a\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u5728\u67e5\u8be2\u65f6\u518d\u8f6c\u6362\u4e3a date \u7c7b\u578b\uff0c\u4e0e [&hellip;]<\/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-7280","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7280","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=7280"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7280\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}