{"id":960,"date":"2018-09-17T18:51:38","date_gmt":"2018-09-17T09:51:38","guid":{"rendered":"https:\/\/chat-messenger.com\/?p=960"},"modified":"2018-12-23T01:55:16","modified_gmt":"2018-12-22T16:55:16","slug":"dateformat-setlenient","status":"publish","type":"post","link":"https:\/\/chat-messenger.com\/th\/\u0e1a\u0e25\u0e47\u0e2d\u0e01\/java\/\u0e23\u0e39\u0e1b\u0e41\u0e1a\u0e1a\u0e27\u0e31\u0e19\u0e17\u0e35\u0e48\u0e1c\u0e48\u0e2d\u0e19\u0e1b\u0e23\u0e19","title":{"rendered":"\u0e01\u0e32\u0e23\u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a\u0e04\u0e27\u0e32\u0e21\u0e16\u0e39\u0e01\u0e15\u0e49\u0e2d\u0e07\/\u0e01\u0e32\u0e23\u0e21\u0e35\u0e2d\u0e22\u0e39\u0e48\u0e02\u0e2d\u0e07\u0e27\u0e31\u0e19\u0e17\u0e35\u0e48 Java"},"content":{"rendered":"<h2 class=\"common_title\"><a name=\"0\"><strong>\u0e0a\u0e27\u0e32<\/strong> <strong>\u0e27\u0e31\u0e19\u0e17\u0e35\u0e48<\/strong>\u0e01\u0e32\u0e23\u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a\u0e04\u0e27\u0e32\u0e21\u0e16\u0e39\u0e01\u0e15\u0e49\u0e2d\u0e07\/\u0e21\u0e35\u0e2d\u0e22\u0e39\u0e48 <strong>Calendar.setLenient()<\/strong><\/a><\/h2>\n<p>\n<strong>\u0e0a\u0e27\u0e32<\/strong>\u0e43\u0e19<strong>\u0e01\u0e32\u0e23\u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a\u0e04\u0e27\u0e32\u0e21\u0e16\u0e39\u0e01\u0e15\u0e49\u0e2d\u0e07\/\u0e01\u0e32\u0e23\u0e21\u0e35\u0e2d\u0e22\u0e39\u0e48\u0e02\u0e2d\u0e07\u0e27\u0e31\u0e19\u0e17\u0e35\u0e48<\/strong>\u0e19\u0e35\u0e48\u0e04\u0e37\u0e2d\u0e42\u0e1b\u0e23\u0e41\u0e01\u0e23\u0e21\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e17\u0e35\u0e48\u0e17\u0e33\u0e2a\u0e34\u0e48\u0e07\u0e19\u0e35\u0e49<br \/>\n\u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a\u0e27\u0e48\u0e32\u0e2a\u0e15\u0e23\u0e34\u0e07\u0e27\u0e31\u0e19\u0e17\u0e35\u0e48\u0e17\u0e35\u0e48\u0e23\u0e30\u0e1a\u0e38 (yyyy\/MM\/dd \u0e2b\u0e23\u0e37\u0e2d yyyy-MM-dd) \u0e21\u0e35\u0e2d\u0e22\u0e39\u0e48\u0e43\u0e19\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e2b\u0e23\u0e37\u0e2d\u0e44\u0e21\u0e48<\/p>\n<p><strong>java.text.DateFormat<\/strong>\u0e23\u0e30\u0e14\u0e31\u0e1a<strong>\u0e15\u0e31\u0e49\u0e07\u0e04\u0e48\u0e32\u0e1c\u0e48\u0e2d\u0e19\u0e1c\u0e31\u0e19()<\/strong>\u0e42\u0e14\u0e22\u0e01\u0e32\u0e23\u0e23\u0e30\u0e1a\u0e38\u0e40\u0e17\u0e47\u0e08 \u0e04\u0e38\u0e13\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e14\u0e33\u0e40\u0e19\u0e34\u0e19\u0e01\u0e32\u0e23\u0e41\u0e22\u0e01\u0e27\u0e34\u0e40\u0e04\u0e23\u0e32\u0e30\u0e2b\u0e4c\u0e27\u0e31\u0e19\u0e17\u0e35\u0e48\u0e17\u0e35\u0e48\u0e40\u0e02\u0e49\u0e21\u0e07\u0e27\u0e14\u0e44\u0e14\u0e49 (*\u0e04\u0e25\u0e32\u0e2a DateFormat \u0e2d\u0e22\u0e39\u0e48\u0e20\u0e32\u0e22\u0e43\u0e19<strong>setLenient() \u0e43\u0e19\u0e04\u0e25\u0e32\u0e2a java.util.Calendar<\/strong>\u0e01\u0e33\u0e25\u0e31\u0e07\u0e42\u0e17\u0e23\u0e21\u0e32 )<br \/>\n\u0e27\u0e34\u0e18\u0e35\u0e01\u0e32\u0e23\u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a\u0e19\u0e35\u0e49\u0e43\u0e0a\u0e49\u0e1b\u0e23\u0e30\u0e42\u0e22\u0e0a\u0e19\u0e4c\u0e08\u0e32\u0e01\u0e02\u0e49\u0e2d\u0e40\u0e17\u0e47\u0e08\u0e08\u0e23\u0e34\u0e07\u0e17\u0e35\u0e48\u0e27\u0e48\u0e32 \u0e16\u0e49\u0e32\u0e04\u0e38\u0e13\u0e40\u0e23\u0e35\u0e22\u0e01\u0e43\u0e0a\u0e49\u0e27\u0e34\u0e18\u0e35 parse() \u0e14\u0e49\u0e27\u0e22\u0e27\u0e31\u0e19\u0e17\u0e35\u0e48\u0e17\u0e35\u0e48\u0e44\u0e21\u0e48\u0e16\u0e39\u0e01\u0e15\u0e49\u0e2d\u0e07\u0e2b\u0e23\u0e37\u0e2d\u0e27\u0e31\u0e19\u0e17\u0e35\u0e48\u0e44\u0e21\u0e48\u0e21\u0e35\u0e2d\u0e22\u0e39\u0e48 ParseException \u0e08\u0e30\u0e40\u0e01\u0e34\u0e14\u0e02\u0e36\u0e49\u0e19\n<\/p>\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=\"1\">\u0e42\u0e1b\u0e23\u0e41\u0e01\u0e23\u0e21\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07<\/a><\/h2>\n<pre class=\"sample_src\">\/** * \u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a\u0e04\u0e27\u0e32\u0e21\u0e16\u0e39\u0e01\u0e15\u0e49\u0e2d\u0e07\u0e02\u0e2d\u0e07\u0e27\u0e31\u0e19\u0e17\u0e35\u0e48 * \u0e2a\u0e48\u0e07\u0e04\u0e37\u0e19\u0e27\u0e48\u0e32\u0e2a\u0e15\u0e23\u0e34\u0e07\u0e27\u0e31\u0e19\u0e17\u0e35\u0e48\u0e17\u0e35\u0e48\u0e23\u0e30\u0e1a\u0e38 (yyyy\/MM\/dd \u0e2b\u0e23\u0e37\u0e2d yyyy-MM-dd) * \u0e21\u0e35\u0e2d\u0e22\u0e39\u0e48\u0e43\u0e19\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e2b\u0e23\u0e37\u0e2d\u0e44\u0e21\u0e48 * @param strDate \u0e2a\u0e15\u0e23\u0e34\u0e07\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a * @return \u0e08\u0e23\u0e34\u0e07\u0e2b\u0e32\u0e01\u0e21\u0e35\u0e27\u0e31\u0e19\u0e17\u0e35\u0e48\u0e2d\u0e22\u0e39\u0e48 *\/ public static boolean checkDate(String strDate) { if (strDate == null || strDate.length() != 10) { Throw new IllegalArgumentException ( &quot;\u0e2d\u0e32\u0e23\u0e4c\u0e01\u0e34\u0e27\u0e40\u0e21\u0e19\u0e15\u0e4c string [&quot;+ strDate +&quot;]&quot; + &quot;is invalid.&quot;); } strDate = strDate.replace(&#039;-&#039;, &#039;\/&#039;); DateFormat format = DateFormat.getDateInstance(); \/\/ \u0e15\u0e31\u0e49\u0e07\u0e04\u0e48\u0e32\u0e27\u0e48\u0e32\u0e08\u0e30\u0e14\u0e33\u0e40\u0e19\u0e34\u0e19\u0e01\u0e32\u0e23\u0e27\u0e31\u0e19\u0e17\u0e35\u0e48\u0e17\u0e35\u0e48\u0e40\u0e02\u0e49\u0e21\u0e07\u0e27\u0e14\u0e2b\u0e23\u0e37\u0e2d\u0e44\u0e21\u0e48 \/\u0e27\u0e34\u0e40\u0e04\u0e23\u0e32\u0e30\u0e2b\u0e4c\u0e40\u0e27\u0e25\u0e32 format.setLenient(false); try { format.parse(strDate); return true; } catch (\u0e02\u0e49\u0e2d\u0e22\u0e01\u0e40\u0e27\u0e49\u0e19 e) { return false; } }\r\n<\/pre>\n<h2 class=\"common_title\"><a name=\"2\">\u0e1c\u0e25\u0e01\u0e32\u0e23\u0e14\u0e33\u0e40\u0e19\u0e34\u0e19\u0e01\u0e32\u0e23<\/a><\/h2>\n<p>\u25c6\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e01\u0e32\u0e23\u0e14\u0e33\u0e40\u0e19\u0e34\u0e19\u0e01\u0e32\u0e23<\/p>\n<pre class=\"sample_src\">\u0e42\u0e21\u0e06\u0e30\u0e04\u0e07\u0e2a\u0e32\u0e18\u0e32\u0e23\u0e13\u0e30 main (String [] args) { System.out.println (checkDate (&quot;2007-01-01&quot;)); System.out.println (checkDate (&quot;2007\/02\/31&quot;)); System.out .println(checkDate(&quot;aaaa\/02\/31&quot;)); }\r\n<\/pre>\n<p>\u25c6\u0e1c\u0e25\u0e25\u0e31\u0e1e\u0e18\u0e4c\u0e40\u0e2d\u0e32\u0e17\u0e4c\u0e1e\u0e38\u0e15<\/p>\n<pre class=\"console\">\u0e08\u0e23\u0e34\u0e07\u0e40\u0e17\u0e47\u0e08\u0e40\u0e17\u0e47\u0e08\r\n<\/pre>","protected":false},"excerpt":{"rendered":"<p>\u0e01\u0e32\u0e23\u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a\u0e04\u0e27\u0e32\u0e21\u0e16\u0e39\u0e01\u0e15\u0e49\u0e2d\u0e07\/\u0e01\u0e32\u0e23\u0e21\u0e35\u0e2d\u0e22\u0e39\u0e48\u0e02\u0e2d\u0e07\u0e27\u0e31\u0e19\u0e17\u0e35\u0e48\u0e02\u0e2d\u0e07 Java Calendar.setLenient() \u0e01\u0e32\u0e23\u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a\u0e04\u0e27\u0e32\u0e21\u0e16\u0e39\u0e01\u0e15\u0e49\u0e2d\u0e07\u0e02\u0e2d\u0e07\u0e27\u0e31\u0e19\u0e17\u0e35\u0e48\/\u0e01\u0e32\u0e23\u0e21\u0e35\u0e2d\u0e22\u0e39\u0e48\u0e02\u0e2d\u0e07\u0e27\u0e31\u0e19\u0e17\u0e35\u0e48\u0e43\u0e19 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\/th\/wp-json\/wp\/v2\/posts\/960"}],"collection":[{"href":"https:\/\/chat-messenger.com\/th\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chat-messenger.com\/th\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chat-messenger.com\/th\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/chat-messenger.com\/th\/wp-json\/wp\/v2\/comments?post=960"}],"version-history":[{"count":6,"href":"https:\/\/chat-messenger.com\/th\/wp-json\/wp\/v2\/posts\/960\/revisions"}],"predecessor-version":[{"id":9055,"href":"https:\/\/chat-messenger.com\/th\/wp-json\/wp\/v2\/posts\/960\/revisions\/9055"}],"wp:attachment":[{"href":"https:\/\/chat-messenger.com\/th\/wp-json\/wp\/v2\/media?parent=960"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chat-messenger.com\/th\/wp-json\/wp\/v2\/categories?post=960"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chat-messenger.com\/th\/wp-json\/wp\/v2\/tags?post=960"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}