{"id":101,"date":"2023-02-18T06:40:31","date_gmt":"2023-02-17T22:40:31","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=101"},"modified":"2023-02-18T06:40:53","modified_gmt":"2023-02-17T22:40:53","slug":"java-judge-weekend","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/18\/java-judge-weekend\/","title":{"rendered":"Java\u5224\u65ad\u662f\u5426\u5468\u672b"},"content":{"rendered":"<pre><code class=\"language-java\">import java.time.LocalDateTime;\nimport java.util.Calendar;\nimport java.util.Date;\nimport java.util.TimeZone;\nimport java.time.ZoneId;\n\npublic class WeekendTest {\n\n    public static void main(String[] args) throws Exception {\n        Date cnDate = Date.from(LocalDateTime.now().atZone(TimeZone.getTimeZone(&quot;GMT+8&quot;).toZoneId()).toInstant());\n        Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone(&quot;GMT+8&quot;));  \/\/\u4e0d\u5f71\u54cd\n        \/\/Calendar calendar = Calendar.getInstance();  \/\/\u4e0d\u5f71\u54cd\n\n        \/\/calendar.setTime(cnDate);  \/\/\u9519\u8bef\n        calendar.setTime(Date.from(LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant()));  \/\/\u6b63\u786e\n        System.out.println(calendar.getTime());\n        if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {\n            System.out.println(&quot;WEEKEND&quot;);\n        } else {\n            System.out.println(&quot;NOT WEEKEND&quot;);\n        }\n    }\n\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>import java.time.LocalDateTime; import java.util.Calend [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[],"class_list":["post-101","post","type-post","status-publish","format-standard","hentry","category-java-basic"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/101","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=101"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/101\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}