I'm trying to set mindate and maxdate in a Primefaces Calendar control. I get an error java.lang.IllegalArgumentException: Cannot format given Object as a Date
The code is very simple:
<p:calendar value="" pattern="MM/dd/yyyy" mindate="01/01/2012" maxdate="05/31/2012" mode="inline"/>
I assume the problem is the format used in the strings for the mindate and maxdate attributes, but I can't see what the problem would be, especially as I've explicitly defined the format in the pattern attribute.
Best Answer
Nothing wrong with the
format
or themindate
/maxdate
.The problem is actually the
value=""
. I presume you're trying to display blank as the default. The<p:calendar/>
component being a strictly-typed component will attempt to parse and convert" "
to ajava.util.Date
object. Obviously that's going to cause it to choke.You're better off binding the
value
attribute to an uninitializedDate
field in your backing bean or setting a default value with thepageDate
attribute, which is not as strongly-typed (takes anObject
)