title: How to check if string representing timestamp is valid date in Java?
body: <p>Previously I check <a href="https://stackoverflow.com/questions/5902310/how-do-i-validate-a-timestamp">How do I validate a timestamp?</a> and I try to base my code on that, I have an string that has the date: <code>String date = "2013-01-28 20:46:34"</code> and I want to check if is valid by calling <code>isTimeStampValid</code> method, their implementation is:</p>
  
  <pre>
      public boolean isTimeStampValid(String timeStamp)
      {
          SimpleDateFormat format = new java.text.SimpleDateFormat("yyyy-MM-dd HH-mm:ss");
  
          try{
              format.parse(timeStamp);
              return true;
          }
          catch(ParseException e) {
              return false;
          }
      }
  </pre>
  
  <p>But the method returns <code>false</code> and I suspect that "yyyy-MM-dd HH-mm:ss" is incorrect but I didn't found any solution (<a href="http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html" rel="nofollow noreferrer">SimpleDateFormat java doc</a>). How can I do the method return <code>true</code> when appropiate?</p>