title: How do I validate a timestamp?
body: <p>my application takes in a string like this "2002-10-15 10:55:01.000000". I need to validate that the string is a valid for a db2 timestamp.</p>
  
  <p>How can I do this?</p>
  
  <p>EDIT: This mostly works</p>
  
  <pre><code>     public static boolean isTimeStampValid(String inputString) {
       SimpleDateFormat format = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSSSS");
          try {
              format.parse(inputString);
              return true;
          } catch (ParseException e) {
              return false;
          }
       }
  </code></pre>
  
  <p>The problem is that if I pass it a bad format for milliseconds like "2011-05-02 10:10:01.0av" this will pass validation. I am assuming that since the first millisecond character is valid then it just truncates the rest of the string.</p>