Vote count:
0
I have a log file which will have one date time. But to avoid any issues, I would like to validate the date time or just the date from date time object when I read the file.
So if my file has "Mon, 13 Apr 2015 12:43:23 -0500" as data in it, I tried doing DateTime.parse(filef.readline()) or Date.parse(filef.readline()) to get the date object and then checking it. This returns the date while the data in file is a date. However if the data in file is some junked text like "this is a junk text for testing", my solution returns me "Mon, 1 Jun 2015 00:00:00 -5000" and my check for datetime/date becomes valid.
What is the best way to check the data in the file is a valid date/datetime?
asked 1 min ago
Validating date/datetime object data in a file
Aucun commentaire:
Enregistrer un commentaire