In Java we can use SimpleDateFormat to parse a date like below:
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
Date d = sdf.parse("12/21/2012"); //matched to December 21, 2012
but if our date changes to
Date d = sdf.parse("12-21-2012"); //ParseException!!
is there an easy way to expand this functionality to all sets of numbers by intermixing a regex? In other words, I don't care what the delimiter(s) are as long as the format matches. E.G:
SimpleDateFormat sdf = new SimpleDateFormat("MM[^0-9]dd[^0-9]yyyy");
Date d = sdf.parse("12/21/2012"); //matched to December 21, 2012
Date d = sdf.parse("12-21-2012"); //matched to December 21, 2012