I have this situation where I am reading about 130K records containing dates stored as String fields. Some records contain blanks (nulls), some contain strings like this: \'
you could use split to determine which format to use
String[] parts = date.split("-"); df = (parts.length==3 ? format1 : format2);
That assumes they are all in one or the other format, you could improve the checking if need be