tag:blogger.com,1999:blog-865923359735383241.post457979814869867721..comments2023-10-29T07:27:09.012-06:00Comments on Ccna final exam - java, php, javascript, ios, cshap all in one: How do I determine if a string is date format?Unknownnoreply@blogger.comBlogger5125tag:blogger.com,1999:blog-865923359735383241.post-65370541493602294252012-02-12T23:54:48.156-07:002012-02-12T23:54:48.156-07:00You can use Date.parse( your_string ) and check th...You can use Date.parse( your_string ) and check the result. This will check any allowed date format, unlike regex.<br />http://www.w3schools.com/jsref/jsref_parse.asp<br />Just realized your string is always in a given format, still unlike regex that function will check if day/month/year are correct etc. So maybe carry 2 checks: 1st to check string format, 2nd to check if numbers are right.Userhttps://www.blogger.com/profile/11557173689529910046noreply@blogger.comtag:blogger.com,1999:blog-865923359735383241.post-86084978386812530062012-02-12T23:54:47.451-07:002012-02-12T23:54:47.451-07:00Try matching with the following regular expression...Try matching with the following regular expression:<br /><br />var pattern = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/;<br />var d = "2012-02-05T07:42:47.000Z";<br />if(d.match(pattern) !== null){<br /> //success<br />} else {<br /> //failed<br />}Userhttps://www.blogger.com/profile/11557173689529910046noreply@blogger.comtag:blogger.com,1999:blog-865923359735383241.post-35579916776327217862012-02-12T23:54:46.743-07:002012-02-12T23:54:46.743-07:00The ones for which !isNaN(+new Date(s))?The ones for which !isNaN(+new Date(s))?Userhttps://www.blogger.com/profile/11557173689529910046noreply@blogger.comtag:blogger.com,1999:blog-865923359735383241.post-64039444426162135782012-02-12T23:54:46.051-07:002012-02-12T23:54:46.051-07:00Isn't there are way to parse it directly into ...Isn't there are way to parse it directly into Java without a regex?<br />With a regex you know IF it is a date but if you need also the value I should check on some date parser function.Userhttps://www.blogger.com/profile/11557173689529910046noreply@blogger.comtag:blogger.com,1999:blog-865923359735383241.post-60534947573708262522012-02-12T23:54:45.239-07:002012-02-12T23:54:45.239-07:00Regex [0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}...Regex [0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}ZUserhttps://www.blogger.com/profile/11557173689529910046noreply@blogger.com