• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

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
0
mravell
Asked:
mravell
  • 3
1 Solution
 
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
 
suprapto45Commented:
Hi Marty,

Unless you want to create custom JSP tag.

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

Regards
Dave
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now