{"id":7283,"date":"2024-11-14T15:44:22","date_gmt":"2024-11-14T07:44:22","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7283\/"},"modified":"2024-11-14T15:44:22","modified_gmt":"2024-11-14T07:44:22","slug":"spring-boot-%e6%9f%a5%e8%af%a2-mysql-date-%e7%b1%bb%e5%9e%8b%e5%ad%97%e6%ae%b5%ef%bc%8c%e4%b8%ba%e4%bb%80%e4%b9%88%e5%90%8e%e7%ab%af%e6%89%93%e5%8d%b0%e5%87%ba%e7%9a%84%e6%97%a5%e6%9c%9f%e7%b1%bb","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7283\/","title":{"rendered":"Spring Boot \u67e5\u8be2 MySQL DATE \u7c7b\u578b\u5b57\u6bb5\uff0c\u4e3a\u4ec0\u4e48\u540e\u7aef\u6253\u5370\u51fa\u7684\u65e5\u671f\u7c7b\u578b\u53d8\u6210\u4e86 Timestamp\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173068075211278.jpg\" class=\"aligncenter\" title=\"Spring Boot \u67e5\u8be2 MySQL DATE \u7c7b\u578b\u5b57\u6bb5\uff0c\u4e3a\u4ec0\u4e48\u540e\u7aef\u6253\u5370\u51fa\u7684\u65e5\u671f\u7c7b\u578b\u53d8\u6210\u4e86 Timestamp\uff1f\u63d2\u56fe\" alt=\"Spring Boot \u67e5\u8be2 MySQL DATE \u7c7b\u578b\u5b57\u6bb5\uff0c\u4e3a\u4ec0\u4e48\u540e\u7aef\u6253\u5370\u51fa\u7684\u65e5\u671f\u7c7b\u578b\u53d8\u6210\u4e86 Timestamp\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>spring boot \u67e5\u8be2  date \u7c7b\u578b\u5b57\u6bb5<\/strong><\/p>\n<p><strong>\u95ee\u9898\u63cf\u8ff0\uff1a<\/strong><\/p>\n<p>\u5728\u4f7f\u7528 spring boot \u5f00\u53d1\u65f6\uff0c\u6211\u4eec\u9700\u8981\u4ece\u524d\u7aef\u63a5\u6536\u65e5\u671f\u7c7b\u578b\u7684\u6570\u636e\uff0c\u5e76\u5c06\u5176\u5b58\u50a8\u5728 mysql \u7684 date \u7c7b\u578b\u5b57\u6bb5\u4e2d\u3002\u7136\u800c\uff0c\u5728\u4f7f\u7528 mybatis-plus \u67e5\u8be2\u65f6\uff0c\u53d1\u73b0\u540e\u7aef\u6253\u5370\u51fa\u7684\u65e5\u671f\u7c7b\u578b\u5374\u53d8\u6210\u4e86 timestamp\uff0c\u5bfc\u81f4\u67e5\u8be2\u4e0d\u5230\u60f3\u8981\u7684\u6570\u636e\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6cd5\uff1a<\/strong><\/p>\n<p>\u5728 spring boot \u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528 string \u7c7b\u578b\u63a5\u6536\u6765\u81ea\u524d\u7aef\u7684\u65f6\u95f4\u6570\u636e\uff0c\u800c\u65e0\u9700\u4f7f\u7528 date \u7c7b\u578b\u3002\u5c3d\u7ba1 mysql \u5b57\u6bb5\u7684\u7c7b\u578b\u4e3a date \u6216 datetime\uff0c\u6211\u4eec\u4ecd\u7136\u53ef\u4ee5\u901a\u8fc7 string \u7c7b\u578b\u76f4\u63a5\u67e5\u8be2\u3002<\/p>\n<p><strong>\u793a\u4f8b\u4ee3\u7801\uff1a<\/strong><\/p>\n<pre>@ApiModelProperty(value = \"\u65e5\u671f\")\nprivate String lessonDate;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5f53\u6211\u4eec\u4f7f\u7528 mybatis-plus \u67e5\u8be2\u65f6\uff0c\u65e5\u671f\u7c7b\u578b\u4ecd\u4f1a\u81ea\u52a8\u8f6c\u6362\u4e3a timestamp\uff0c\u4f46\u4e0d\u4f1a\u5f71\u54cd\u67e5\u8be2\u7ed3\u679c\u3002<\/p>\n<p><strong>\u539f\u56e0\uff1a<\/strong><\/p>\n<p>spring boot \u4f1a\u6839\u636e\u63a5\u6536\u5230\u7684\u65e5\u671f\u683c\u5f0f\u81ea\u52a8\u8f6c\u6362\u65e5\u671f\u7c7b\u578b\u3002\u5982\u679c\u6211\u4eec\u4f7f\u7528 date \u7c7b\u578b\u63a5\u6536\uff0cspring boot \u5c06\u5176\u8f6c\u6362\u4e3a timestamp \u7c7b\u578b\u3002\u800c\u4f7f\u7528 string \u7c7b\u578b\u63a5\u6536\uff0cspring boot \u5219\u4e0d\u4f1a\u81ea\u52a8\u8f6c\u6362\uff0c\u6570\u636e\u5e93\u4f1a\u6839\u636e\u5b57\u6bb5\u7c7b\u578b\u5bf9\u5b57\u7b26\u4e32\u8fdb\u884c\u76f8\u5e94\u7684\u8f6c\u6362\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fSpring Boot \u67e5\u8be2 MySQL DATE \u7c7b\u578b\u5b57\u6bb5\uff0c\u4e3a\u4ec0\u4e48\u540e\u7aef\u6253\u5370\u51fa\u7684\u65e5\u671f\u7c7b\u578b\u53d8\u6210\u4e86 Timestamp\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>spring boot \u67e5\u8be2 date \u7c7b\u578b\u5b57\u6bb5 \u95ee\u9898\u63cf\u8ff0\uff1a \u5728\u4f7f\u7528 spring boot \u5f00\u53d1\u65f6\uff0c\u6211\u4eec\u9700\u8981\u4ece\u524d\u7aef\u63a5\u6536\u65e5\u671f\u7c7b\u578b\u7684\u6570\u636e\uff0c\u5e76\u5c06\u5176\u5b58\u50a8\u5728 mysql \u7684 date \u7c7b\u578b\u5b57\u6bb5\u4e2d\u3002\u7136\u800c\uff0c\u5728\u4f7f\u7528 mybatis-plus \u67e5\u8be2\u65f6\uff0c\u53d1\u73b0\u540e\u7aef\u6253\u5370\u51fa\u7684\u65e5\u671f\u7c7b\u578b\u5374\u53d8\u6210\u4e86 timestamp\uff0c\u5bfc\u81f4\u67e5\u8be2\u4e0d\u5230\u60f3\u8981\u7684\u6570\u636e\u3002 \u89e3\u51b3\u65b9\u6cd5\uff1a \u5728 spring boot \u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528 string \u7c7b\u578b\u63a5\u6536\u6765\u81ea\u524d\u7aef\u7684\u65f6\u95f4\u6570\u636e\uff0c\u800c\u65e0\u9700\u4f7f\u7528 date \u7c7b\u578b\u3002\u5c3d\u7ba1 mysql \u5b57\u6bb5\u7684\u7c7b\u578b\u4e3a date \u6216 datetime\uff0c\u6211\u4eec\u4ecd\u7136\u53ef\u4ee5\u901a\u8fc7 string \u7c7b\u578b\u76f4\u63a5\u67e5\u8be2\u3002 \u793a\u4f8b\u4ee3\u7801\uff1a @ApiModelProperty(value = &#8220;\u65e5\u671f&#8221;) private String lessonDate; \u767b\u5f55\u540e\u590d\u5236 \u5f53\u6211\u4eec\u4f7f\u7528 mybatis-plus \u67e5\u8be2\u65f6\uff0c\u65e5\u671f\u7c7b\u578b\u4ecd\u4f1a\u81ea\u52a8\u8f6c\u6362\u4e3a timestamp\uff0c\u4f46\u4e0d\u4f1a\u5f71\u54cd\u67e5\u8be2\u7ed3\u679c\u3002 \u539f\u56e0\uff1a spring boot \u4f1a\u6839\u636e\u63a5\u6536\u5230\u7684\u65e5\u671f\u683c\u5f0f\u81ea\u52a8\u8f6c\u6362\u65e5\u671f\u7c7b\u578b\u3002\u5982\u679c\u6211\u4eec\u4f7f\u7528 date \u7c7b\u578b\u63a5\u6536\uff0cspring boot \u5c06\u5176\u8f6c\u6362\u4e3a timestamp \u7c7b\u578b\u3002\u800c\u4f7f\u7528 [&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-7283","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7283","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=7283"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7283\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7283"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7283"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}