I need to check the format of a date string coming from a csv file. I am using the csvReader parser (au.com.bytecode.opencsv.CSVReader). Below is the code that I use to get data from a csv reader and change it in a date format.
def String strToDate = csvrow[monatVal]
myDate = new Date().parse("dd.MM.yy HH:mm",strToDate)
The problem is that there is a date entry in the CSV file, for example. '41 .01.10 12:22 ', I have the following when I type' myDate '
myDate = '10.02.10 12:22' β It adds 10 days to the month of February.
I would like to check the date format check here. Is there any way to check dateString during parsing?
Thanks in advance, Sudheer
Parsing is probably best as a static method, i.e. Date.parse (format, input) that returns a new Date instance - right?
source share