I'm having a small problem with a JSP page. I'm using Stripes as framework but this should not be that relevant.
Basically I have a bean that returns via a getter a date in the form of a GregorianCalendar
.
I have to display this date in JSP. When I try:
<fmt:formatDate type="both" dateStyle="full" value="${myObject.itsGregorian}">
I get an exception saying that he is unable to convert GregorianCalendar
to Date
.
I understand that fmt:formatDate
formats a Date
object and not a GregorianCalendar
, but is there a way to turn around it?
Since this is an assignment and I've got a pre-coded Bean I'm not allowed to touch the bean, so I can't transform its getter for the date to return a Date
.
How can I solve this the best?
It indeed only supports java.util.Date
. You need to call Calendar#getTime()
to get it out the calendar.
<fmt:formatDate type="both" dateStyle="full" value="${myObject.itsGregorian.time}">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With