{"id":746,"date":"2020-01-16T14:50:28","date_gmt":"2020-01-16T06:50:28","guid":{"rendered":"http:\/\/prayerlaputa.com\/?p=746"},"modified":"2020-01-16T14:50:28","modified_gmt":"2020-01-16T06:50:28","slug":"java%e4%b8%ad%e6%97%a5%e6%9c%9f%e6%a0%bc%e5%bc%8f%e5%8c%96yyyymmdd%e5%92%8cyyyymmdd%e7%9a%84%e5%8c%ba%e5%88%ab","status":"publish","type":"post","link":"http:\/\/prayerlaputa.com\/?p=746","title":{"rendered":"Java\u4e2d\u65e5\u671f\u683c\u5f0f\u5316yyyyMMdd\u548cYYYYMMdd\u7684\u533a\u522b"},"content":{"rendered":"<h1 id=\"java%E4%B8%AD%E6%97%A5%E6%9C%9F%E6%A0%BC%E5%BC%8F%E5%8C%96yyyymmdd%E5%92%8Cyyyymmdd%E7%9A%84%E5%8C%BA%E5%88%AB\" class=\"mume-header\">Java\u4e2d\u65e5\u671f\u683c\u5f0f\u5316yyyyMMdd\u548cYYYYMMdd\u7684\u533a\u522b<\/h1>\n<p>\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<pre class=\"language-\" data-role=\"codeBlock\" data-info=\"\"><code> public static void main(String[] args) {\r\n        \/\/YYYY \u662f\u8868\u793a\uff1a\u5f53\u5929\u6240\u5728\u7684\u5468\u5c5e\u4e8e\u7684\u5e74\u4efd\uff0c\u4e00\u5468\u4ece\u5468\u65e5\u5f00\u59cb\uff0c\u5468\u516d\u7ed3\u675f\uff0c\u53ea\u8981\u672c\u5468\u8de8\u5e74\uff0c\u90a3\u4e48\u8fd9\u5468\u5c31\u7b97\u5165\u4e0b\u4e00\u5e74\u3002\r\n        \/\/2019-12-29\u81f32020-1-4\u8de8\u5e74\u5468\r\n        Calendar calendar = Calendar.getInstance();\r\n        \/\/2019-12-28\r\n        calendar.set(2019, Calendar.DECEMBER, 28);  \r\n        Date strDate1 = calendar.getTime(); \r\n        \/\/2019-12-29\r\n        calendar.set(2019, Calendar.DECEMBER, 29);  \r\n        Date strDate2 = calendar.getTime(); \r\n        \/\/ 2019-12-31  \r\n        calendar.set(2019, Calendar.DECEMBER, 31);  \r\n        Date strDate3 = calendar.getTime();  \r\n        \/\/ 2020-01-01  \r\n        calendar.set(2020, Calendar.JANUARY, 1);  \r\n        Date strDate4 = calendar.getTime();  \r\n        \r\n        DateFormat df1 = new SimpleDateFormat(\"yyyyMMdd\");\r\n        DateFormat df2 = new SimpleDateFormat(\"YYYYMMdd\");\r\n        \/\/yyyyMMdd\r\n        System.out.println(\"yyyyMMdd\");\r\n        System.out.println(\"2019-12-28: \" + df1.format(strDate1)); \r\n        System.out.println(\"2019-12-29: \" + df1.format(strDate2)); \r\n        System.out.println(\"2019-12-31: \" + df1.format(strDate3));  \r\n        System.out.println(\"2020-01-01: \" + df1.format(strDate4));  \r\n        \/\/YYYYMMdd\r\n        System.out.println(\"YYYYMMdd\");\r\n        System.out.println(\"2019-12-28: \" + df2.format(strDate1));\r\n        System.out.println(\"2019-12-29: \" + df2.format(strDate2));\r\n        System.out.println(\"2019-12-31: \" + df2.format(strDate3));  \r\n        System.out.println(\"2020-01-01: \" + df2.format(strDate4));\r\n    }\r\n<\/code><\/pre>\n<p>\u8f93\u51fa\u7ed3\u679c\uff1a<!--more--><\/p>\n<pre class=\"language-\" data-role=\"codeBlock\" data-info=\"\"><code>yyyyMMdd\r\n2019-12-28: 20191228\r\n2019-12-29: 20191229\r\n2019-12-31: 20191231\r\n2020-01-01: 20200101\r\nYYYYMMdd\r\n2019-12-28: 20191228\r\n2019-12-29: 20201229\r\n2019-12-31: 20201231\r\n2020-01-01: 20200101\r\n<\/code><\/pre>\n<p>\u539f\u56e0\uff1a<br \/>\nYYYY\u662fweek-based-year\uff0c\u8868\u793a\uff1a\u5f53\u5929\u6240\u5728\u7684\u5468\u5c5e\u4e8e\u7684\u5e74\u4efd\uff0c\u4e00\u5468\u4ece\u5468\u65e5\u5f00\u59cb\uff0c\u5468\u516d\u7ed3\u675f\uff0c\u53ea\u8981\u672c\u5468\u8de8\u5e74\uff0c\u90a3\u4e48\u8fd9\u5468\u5c31\u7b97\u5165\u4e0b\u4e00\u5e74\u3002\u6240\u4ee52019\u5e7412\u670831\u65e5\u90a3\u5929\u5728\u8fd9\u79cd\u8868\u8ff0\u65b9\u5f0f\u4e0b\u5c31\u5df2\u7ecf 2020 \u5e74\u4e86\u3002\u800c\u5f53\u4f7f\u7528yyyy\u7684\u65f6\u5019\uff0c\u5c31\u8fd8\u662f 2019 \u5e74\u3002<\/p>\n<p>\u76f8\u5173\u8bf4\u660e\uff1a<br \/>\n<a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/time\/format\/DateTimeFormatter.html#patterns\">https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/time\/format\/DateTimeFormatter.html#patterns<\/a><br \/>\n<a href=\"https:\/\/nakedsecurity.sophos.com\/2019\/12\/23\/serious-security-the-decade-ending-y2k-bug-that-wasnt\/\">https:\/\/nakedsecurity.sophos.com\/2019\/12\/23\/serious-security-the-decade-ending-y2k-bug-that-wasnt\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java\u4e2d\u65e5\u671f\u683c\u5f0f\u5316yyyyMMdd\u548cYYYYMMdd\u7684\u533a\u522b \u793a\u4f8b\u4ee3\u7801\uff1a public static void <a href='http:\/\/prayerlaputa.com\/?p=746' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[6],"tags":[33],"_links":{"self":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/posts\/746"}],"collection":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=746"}],"version-history":[{"count":1,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/posts\/746\/revisions"}],"predecessor-version":[{"id":747,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/posts\/746\/revisions\/747"}],"wp:attachment":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=746"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=746"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=746"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}