Universal Date Parser.

It is easy to read the Date object from a string in Java. The task can be quite tricky when you are dealing with a third party data feed and you are not really sure about the format in which the date is going to come.

The below example handles most of the date formats and returns the date object. The format supported are [dd MMM,yy], [MM/dd/yy], [MMddyy], [yyyy-MM-dd], [dd-MMM-yy], [dd MMM yy], [MMM dd, yy], [yyyyMMdd].

You can easily add more formats but needs to make sure they and not conflicted with the existing things. For example you should not add [dd/MM/yy] as it will conflict with [MM/dd/yy] but it can be replaced.