Hello,
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.
def String strToDate = csvrow[monatVal]
myDate = new Date().parse("dd.MM.yy HH:mm",strToDate)
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'
myDate = '10.02.10 12:22'
--> Its adding 10 days to the Feb month.
I would like here a validation check for the date format. Is there a way to check the dateString while parsing?
Thanks in advance, Sudheer
Parse, it is probably best as a static method, i.e. Date.parse( format, input ), that returns a new Date instance – right?