{"id":963,"date":"2018-09-17T18:52:48","date_gmt":"2018-09-17T09:52:48","guid":{"rendered":"https:\/\/chat-messenger.com\/?p=963"},"modified":"2018-12-23T01:52:16","modified_gmt":"2018-12-22T16:52:16","slug":"calendar-getactualmaximum","status":"publish","type":"post","link":"https:\/\/chat-messenger.com\/en\/blog\/java\/calendar-getactualmaximum","title":{"rendered":"Java Get end-of-month date"},"content":{"rendered":"<h2 class=\"common_title\"><a name=\"0\"><strong>Java <\/strong><strong>End of month date<\/strong>Retrieve the <strong>Calendar.getActualMaximum()<\/strong><\/a><\/h2>\n<p>\n<strong>Java<\/strong>of the date specified in<strong>End of month date<\/strong>The following is a sample program to obtain<br \/>\n<strong>Calendar<\/strong>Class<strong>getActualMaximum(Calendar.DATE)<\/strong>indicates certainty, emphasis, etc.<strong>End of month date<\/strong>can be obtained.\n<\/p>\n<h2 class=\"common_title\"><a name=\"1\">sample program<\/a><\/h2>\n<pre class=\"sample_src\">\/**\r\n * Returns the end-of-month date in the given date string (yyyy\/MM\/dd or yyyy-MM-dd)\r\n * Returns the last day of the month in\r\n *\r\n * @param strDate target date string\r\n * @return end-of-month date\r\n *\/\r\npublic static int getLastDay(String strDate) {\r\n    if (strDate == null || strDate.length() ! = 10) {\r\n        throw new IllegalArgumentException(\r\n                \"The argument string [\"+ strDate +\"]\" +\r\n                \"]\" is invalid.\") ;\r\n    }\r\n    int yyyy = Integer.parseInt(strDate.substring(0,4));\r\n    int MM = Integer.parseInt(strDate.substring(5,7)); }\r\n    int dd = Integer.parseInt(strDate.substring(8,10)); int\r\n    Calendar cal = Calendar.getInstance();\r\n    cal.set(yyyy,MM-1,dd);\r\n    int last = cal.getActualMaximum(Calendar.DATE);\r\n    return last; }\r\n}\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\">Execution Result<\/a><\/h2>\n<p>\u25c6Example of Execution<\/p>\n<pre class=\"sample_src\">public static void main(String[] args) {\r\n    System.out.println(getLastDay(\"2007\/01\/01\"));\r\n    System.out.println(getLastDay(\"2007\/02\/01\"));\r\n    System.out.println(getLastDay(\"2008\/02\/01\"));\r\n}\r\n<\/pre>\n<p>\u25c6Output result<\/p>\n<pre class=\"console\">31\r\n28\r\n29\r\n<\/pre>\n<p>*Because 2008 is a leap year, the last day of February is the 29th.<\/p>","protected":false},"excerpt":{"rendered":"<p>Java Get the end date of the month Calendar.getActualMaximum() The date specified in 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\/en\/wp-json\/wp\/v2\/posts\/963"}],"collection":[{"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/comments?post=963"}],"version-history":[{"count":4,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/posts\/963\/revisions"}],"predecessor-version":[{"id":1874,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/posts\/963\/revisions\/1874"}],"wp:attachment":[{"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/media?parent=963"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/categories?post=963"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/tags?post=963"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}