title: Java Regex to check for date and time
body: <p>I'm using Datetime-local in one of the fields for user to input date and time; to check if if has valid format; these should be acceptable:
  'yyyy-mm-dd HH'
  'yyyy-mm-dd HH:MM' (this is the desired one tho)
  'yyyy-mm-dd HH:MM:SS'</p>
  
  <p>I've been trying some variations so far, came up with this but it does not work unfortunately. Where is the mistake?</p>
  
  <pre><code>"\\d{4}-[01]\\d-[0-3]\\d\\s[0-2](\\d:[0-5]\\d:([0-5]\\d)?)?"
  </code></pre>