This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
When I run this piece of code, I get the following exception.
java.lang.IllegalArgumentException: Cannot format given Object as a Date at java.text.DateFormat.format(DateFormat.java:279) at java.text.Format.format(Format.java:133) at Date.formatDate(Date.java:27) at Date.main(Date.java:37)
Could somebody help me with this please??
SCJP 1.4, SCWCD 1.4<br /> <br />Thanks in advance!<br />Jayashree.
Take a look at the signatures on DateFormat. There are some that take a String argument like your "2005-02-10" and return a Date object. And Date is just what the format method expects as an argument. So you need a two step process:
String YYYY-MM-DD -> Date -> String MEDIUM
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi