Viidhya Kishore wrote:Thanks everyone.
Below is the code how I did it.
Looks pretty good. Just a couple of points to consider:
1. I would have broken it up into multiple lines. It's easier to read that way, and there's nothing gained by jamming it all into one line.
2. I would rename the input String from "date" to "dateStr" or "inputDateStr" or something.
3. The coment
//format = MMMM d, yyyy. is confusing and serves no purpose.
4. Catching an exception and then just returning null is not usually the way to go. It's subverting the entire purpose of the exception mechanism. Just catching the exception doesn't fix anything. If you're not going to actually fix the problem, don't bother catching the exception, or at least wrap and re-throw it.