abhi
abhi

Reputation: 1614

check for a date in a particular format

How can i check that if a date is in a particular format like "dd/MM/yyyy" then it will do something but if it is not in this format or if a string like "NA" is there or whatever is there it should throw an error.

Upvotes: 2

Views: 2922

Answers (1)

juergen d
juergen d

Reputation: 204756

You could try to parse the date with SimpleDateFormat. If it works the date is in the expected format.

Upvotes: 3

Related Questions