title: Different SimpleDateFormat parsen
body: <p>I want to check if a date matches one of my defined patterns. Please see below my code.</p>
  
  <pre><code>date = null
  
  List&lt;String&gt; formatStrings = Arrays.asList("yyyy-MM-dd", "dd.MM.yyyy", "yyyyMMdd", "yyyy/MM/dd", "dd/MM/yyyy");
  
          for (String formatStr: formatStrings) {
              try {
                  dateType = new Date(new SimpleDateFormat(formatStr).parse(myCol).getTime());
  
              } catch (ParseException e) {}
          }
          return date;
  </code></pre>
  
  <p>I also tried:</p>
  
  <pre><code> try { 
     for.. }
   catch {}
  </code></pre>
  
  <p>I have also written an unit test to test if my function is working but it is only working when my variable has a pattern: "yyyy-MM-dd" (so the first one in the list). And if I have any other pattern it shows an Exception... </p>
  
  <p>Can you please help me? Which line did I write wrong?</p>