Tags and Calendars

I'm fairly new to Struts, JSP and tag libraries and am wondering if there is a way around this problem.

I have the code:

<bean:write name="version" property="created" format="h:mm a, EEEE, MMMM d, yyyy"/>

As long as getCreated() on the version object returns a Date object this works fine.

If however getCreated() returns a Calendar object it breaks. Not really surprising I guess since it expects a Date.

Is there an easy way to modify the bean:write tag above so that it converts the Calendar into a Date (i.e. call the getTime on the calendar object) and will therefore work?


Regards
Marty
mravellAsked:
Who is Participating?
 
suprapto45Connect With a Mentor Commented:
Hi Marty,

Unless you want to create custom JSP tag.

http://www-106.ibm.com/developerworks/web/library/j-pj2ee8/

Regards
Dave
0
 
suprapto45Commented:
Hi Marty,

Why don't you just use scriptlets <% %> in your JSP page? It is much easier. So do you want to print the current date (today date)? Are you okay not using <bean:write>

Regards
Dave
0
 
mravellAuthor Commented:
I figured I might have to go the scriplet route but was hoping that there was a simple way of doing the same thing with a tag.


Regards
Marty
0
 
suprapto45Commented:
Hi Marty,

Let me try to check whether it is doable from tag.

Regards
Dave
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.