title: how to check if a date pattern is valid in java?
body: <p>Im trying to achive this: I have a method that recieves a string that is the format of a date pattern (example &quot;dd/mm/yyyy&quot;) and the method has to validate if the pattern is valid in java or not.
  Example, lets say I have the following input:</p>
  <pre><code>String input1=&quot;dd/mm/yyyy&quot;;
  String input2=&quot;mm/dd/yyyy&quot;;
  String input3&quot;cceq.der.sads&quot;;
  String input4= &quot;dd-M-yyyy hh:mm:ss&quot;
  
  public Boolean validPatternDate(String in){
  //The code im looking for
  }
  </code></pre>
  <p>The result of each input being applied to the validPatternDate method is going to be:</p>
  <pre><code>input1 True
  input2 True
  input3 False
  input4 True
  </code></pre>
  <p>Is there a way of doing this in java? Thanks</p>