title: Validating date format inside a groovy controller
body: <p>I have to validate the format of a date string coming from a csv file. I use the csvReader(au.com.bytecode.opencsv.CSVReader) parser. Below is the code I use to get the data from the csv reader and change it to a date format. </p>
  
  <p><code>def String strToDate = csvrow[monatVal]</code></p>
  
  <p><code>myDate = new Date().parse("dd.MM.yy HH:mm",strToDate)</code></p>
  
  <p>The problem is that in the CSV file there exists a date entry for eg. '41.01.10 12:22', i have the following when i print 'myDate'</p>
  
  <p><code>myDate = '10.02.10 12:22'</code> --> Its adding 10 days to the Feb month.</p>
  
  <p>I would like here a validation check for the date format. Is there a way to check the dateString while parsing? </p>
  
  <p>Thanks in advance,
  Sudheer</p>
  
  <p>Parse, it is probably best as a static method, i.e. Date.parse( format, input ), that returns a new Date instance – right?</p>