Need Java Help: converting a String to a Date/Time when the format is not known


New member
I've recently been doing some work in Java/Groovy for my job at an Internet Abuse department, writing code to scan emails and pull out the IP Address and Timestamp information. Pulling out the Timestamp is straightforward enough when I know what format it's going to be written in, but is there any function available which can try to auto-detect the format, or is there a way to write a function which tries multiple specified formats? With our old ticketing system, one of my co-workers wrote scripts in Perl to do this sort of thing using Date::Parse, but the system they moved us to is Java-based, and I only started learning how to write in Groovy/Java a couple of months ago. When I'm writing code to process complaints from a specific sender, I can usually count on the date/time format always being the same, but I'm trying to write code that's a little more generalized. If it can't auto-detect the format, I'd settle for being able to have it try several specified formats. Any help you guys could provide would be awesome, thanks.
I can only think to make a function to filter the diverse scenarios, into an unique string format, in order to be treated like the others after. I don't know how many possible format scenarios they are, if it by dozen, you could make a case for each, if it more and unpredictable, I can't tell.