Thanuja Vishwanath wrote:I am able to convert the given string to date in specific format as below if i know the original date string format . But how do i do this if i am not aware of the original string format.
It depends on what the possible list of unknown formats will be. For example if you were given "02-12-11" without being told the format, would that be February 12, 2011? Or would it be 02 December, 2011? Or perhaps 2002 December 11?
However if you have a list of possible formats which don't have any ambiguities like the example above, then just try them all until you find one which doesn't throw an exception.