Reputation: 1
String fromDate = "12-Oct-2011 14:23:47";
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-mm-dd");
java.util.Date fdate = sdf1.parse(fromDate);
It gives error
java.parseException: unpasable date:"12-Oct-2011 14:23:47"
I want to parse string into date.
Upvotes: 0
Views: 589
Reputation: 691635
Of course: you're trying to parse 12-Oct-2011
with the pattern yyyy-mm-dd
. This pattern means "the year on 4 digits, followed by minutes on 2 digits, followed by the day on two digits".
See the javadoc of SimpleDateFormat
to understand how a pattern must be composed. In your case, it should be dd-MMM-yyyy HH:mm:ss
.
Upvotes: 4