{"id":966,"date":"2018-12-17T18:54:14","date_gmt":"2018-12-17T09:54:14","guid":{"rendered":"https:\/\/chat-messenger.com\/?p=966"},"modified":"2019-07-04T01:23:07","modified_gmt":"2019-07-03T16:23:07","slug":"calendar-day_of_week","status":"publish","type":"post","link":"https:\/\/chat-messenger.com\/vi\/blog\/java\/lich-ngay_trong_tuan","title":{"rendered":"Java T\u00ecm ng\u00e0y hi\u1ec7n t\u1ea1i (h\u00f4m nay) trong tu\u1ea7n"},"content":{"rendered":"<h2 class=\"common_title\"><a name=\"0\">java <strong>L\u1ea5y ng\u00e0y hi\u1ec7n t\u1ea1i (h\u00f4m nay) trong tu\u1ea7n<\/strong>. <strong>L\u1ecbch.DAY_OF_WEEK<\/strong><\/a><\/h2>\n<p>\n<strong>Java<\/strong> \u0110\u00e2y l\u00e0 ch\u01b0\u01a1ng tr\u00ecnh m\u1eabu s\u1eed d\u1ee5ng l\u1edbp L\u1ecbch \u0111\u1ec3 l\u1ea5y ng\u00e0y hi\u1ec7n t\u1ea1i (h\u00f4m nay) trong tu\u1ea7n.<br \/>\n<br \/>\n\u0110\u1ec3 c\u00f3 \u0111\u01b0\u1ee3c, <strong>L\u1ecbch.DAY_OF_WEEK<\/strong> s\u1ebd \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng.\n<\/p>\n<div class=\"point\">\nL\u1ecbch cal = Calendar.getInstance(); <br \/>\nint tu\u1ea7n = cal.get(Calendar.DAY_OF_WEEK);\n<\/div>\n<p><strong>L\u1ecbch.DAY_OF_WEEK<\/strong>Gi\u00e1 tr\u1ecb tr\u1ea3 v\u1ec1 c\u00f3 th\u1ec3 nh\u1eadn \u0111\u01b0\u1ee3c l\u00e0 m\u1ed9t s\u1ed1 t\u1eeb 1 \u0111\u1ebfn 7, v\u1edbi Ch\u1ee7 Nh\u1eadt b\u1eaft \u0111\u1ea7u b\u1eb1ng 1, v\u00ec v\u1eady ch\u01b0\u01a1ng tr\u00ecnh m\u1eabu s\u1eed d\u1ee5ng c\u00e2u l\u1ec7nh switch \u0111\u1ec3 x\u00e1c \u0111\u1ecbnh ng\u00e0y trong tu\u1ea7n.<\/p>\n<h2 class=\"common_title\"><a name=\"1\">ch\u01b0\u01a1ng tr\u00ecnh m\u1eabu<\/a><\/h2>\n<pre class=\"sample_src\">\/** * Tr\u1ea3 v\u1ec1 ng\u00e0y hi\u1ec7n t\u1ea1i trong tu\u1ea7n. * @return Ng\u00e0y hi\u1ec7n t\u1ea1i trong tu\u1ea7n *\/ public static String getDayOfTheWeek() { Calendar cal = Calendar.getInstance(); switch (cal.get(Calendar.DAY_OF_WEEK)) { case Calendar.SUNDAY: return &quot;Sunday&quot;; case Calendar .MONDAY : tr\u1ea3 v\u1ec1 &quot;Th\u1ee9 Hai&quot;; tr\u01b0\u1eddng h\u1ee3p L\u1ecbch.TUESDAY: tr\u1ea3 v\u1ec1 &quot;Th\u1ee9 Ba&quot;; tr\u01b0\u1eddng h\u1ee3p L\u1ecbch.WEDNESDAY: tr\u1ea3 v\u1ec1 &quot;Th\u1ee9 T\u01b0&quot;; tr\u01b0\u1eddng h\u1ee3p L\u1ecbch.THURSDAY: tr\u1ea3 v\u1ec1 &quot;Th\u1ee9 N\u0103m&quot;; tr\u01b0\u1eddng h\u1ee3p L\u1ecbch.FRIDAY: tr\u1ea3 v\u1ec1 &quot;Th\u1ee9 S\u00e1u&quot;; tr\u01b0\u1eddng h\u1ee3p L\u1ecbch .SATURDAY : return &quot;Saturday&quot;; } n\u00e9m IllegalStateException m\u1edbi(); } \/** * Tr\u1ea3 v\u1ec1 ng\u00e0y hi\u1ec7n t\u1ea1i trong tu\u1ea7n. * *Ng\u00e0y trong tu\u1ea7n b\u1ecb b\u1ecf qua. * @return ng\u00e0y hi\u1ec7n t\u1ea1i trong tu\u1ea7n *\/ public static String getDayOfTheWeekShort() { Calendar cal = Calendar.getInstance(); switch (cal.get(Calendar.DAY_OF_WEEK)) { case Calendar.SUNDAY: return &quot;day&quot;; case Calendar .MONDAY : tr\u1ea3 v\u1ec1 &quot;Th\u1ee9 Hai&quot;; tr\u01b0\u1eddng h\u1ee3p L\u1ecbch.TUESDAY: tr\u1ea3 v\u1ec1 &quot;Th\u1ee9 Ba&quot;; tr\u01b0\u1eddng h\u1ee3p L\u1ecbch.WEDNESDAY: tr\u1ea3 v\u1ec1 &quot;Th\u1ee9 T\u01b0&quot;; tr\u01b0\u1eddng h\u1ee3p L\u1ecbch.THURSDAY: tr\u1ea3 v\u1ec1 &quot;Th\u1ee9 N\u0103m&quot;; tr\u01b0\u1eddng h\u1ee3p L\u1ecbch.FRIDAY: tr\u1ea3 v\u1ec1 &quot;Th\u1ee9 S\u00e1u&quot;; tr\u01b0\u1eddng h\u1ee3p L\u1ecbch .SATURDAY : return &quot;earth&quot;; } n\u00e9m IllegalStateException m\u1edbi(); }\t\r\n<\/pre>\n<p><script type=\"text\/javascript\" src=\"https:\/\/chat-messenger.com\/js\/common.js?dd12sssas2223\" charset=\"UTF-8\"><\/script><br \/>\n<script type=\"text\/javascript\"> writePR(); <\/script><\/p>\n<h2 class=\"common_title\"><a name=\"2\">K\u1ebft qu\u1ea3 th\u1ef1c hi\u1ec7n<\/a><\/h2>\n<p>\u25c6V\u00ed d\u1ee5 th\u1ef1c thi<\/p>\n<pre class=\"sample_src\">public static void main(String[] args) { \/\/ Hi\u1ec3n th\u1ecb ng\u00e0y h\u00f4m nay trong tu\u1ea7n. System.out.println(&quot;H\u00f4m nay l\u00e0 &quot;&quot; + getDayOfTheWeek() + &quot;&quot;&quot;); \/\/ Hi\u1ec3n th\u1ecb ng\u00e0y h\u00f4m nay trong tu\u1ea7n. N\u00f3 l\u00e0 m\u1ed9t t\u1eeb vi\u1ebft t\u1eaft. System.out.println(&quot;H\u00f4m nay l\u00e0 &quot;&quot; + getDayOfTheWeekShort() + &quot;&quot;.&quot;); }\r\n<\/pre>\n<p>\u25c6K\u1ebft qu\u1ea3 \u0111\u1ea7u ra<\/p>\n<pre class=\"console\">H\u00f4m nay l\u00e0 th\u1ee9 t\u01b0. H\u00f4m nay l\u00e0 &#039;&#039;N\u01b0\u1edbc&#039;&#039;.\r\n<\/pre>","protected":false},"excerpt":{"rendered":"<p>java L\u1ea5y ng\u00e0y hi\u1ec7n t\u1ea1i (h\u00f4m nay) trong tu\u1ea7n. Calendar.DAY_OF_WEEK L\u1ecbch trong Java [\u2026]<\/p>","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":""},"categories":[19],"tags":[],"_links":{"self":[{"href":"https:\/\/chat-messenger.com\/vi\/wp-json\/wp\/v2\/posts\/966"}],"collection":[{"href":"https:\/\/chat-messenger.com\/vi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chat-messenger.com\/vi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chat-messenger.com\/vi\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/chat-messenger.com\/vi\/wp-json\/wp\/v2\/comments?post=966"}],"version-history":[{"count":7,"href":"https:\/\/chat-messenger.com\/vi\/wp-json\/wp\/v2\/posts\/966\/revisions"}],"predecessor-version":[{"id":3708,"href":"https:\/\/chat-messenger.com\/vi\/wp-json\/wp\/v2\/posts\/966\/revisions\/3708"}],"wp:attachment":[{"href":"https:\/\/chat-messenger.com\/vi\/wp-json\/wp\/v2\/media?parent=966"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chat-messenger.com\/vi\/wp-json\/wp\/v2\/categories?post=966"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chat-messenger.com\/vi\/wp-json\/wp\/v2\/tags?post=966"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}