In my project I need to check if a date string evaluates to a proper Date object. I\'ve decided to allow yyyy-MM-dd, and Date formats [(year, month, date) and (year, month,
You are doing this the wrong way. You should use SimpleDateFormat.
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
Date test = sdf.parse(input);
} catch (ParseException pe) {
//Date is invalid, try next format
}