File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes jstl reformat date exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "jstl reformat date exception" Watch "jstl reformat date exception" New topic

jstl reformat date exception

Shilpa Tendulkar
Ranch Hand

Joined: Jul 29, 2001
Posts: 75
Hi all, I am having bit trouble formating date using jstl.
<fmt:formatDate value="${mydate}" type="DATE" pattern="dd/MM/yyyy"/>
I am using JSTL1.1 standard.jar and JSTL1.1 jstl.jar
and stack trace is

Shilpa Tendulkar
Ranch Hand

Joined: Jul 29, 2001
Posts: 75
After some research I found the solution.
Because my value is string I can not directly use <fmt:formatDate> so I have to parse the date and then format it.
Following is the solution:

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63868

Exactly, in the same way you couldn't pass a string to a method expecting a java.util.Date.

[Asking smart questions] [About Bear] [Books by Bear]
PetriJ Airio

Joined: Dec 18, 2007
Posts: 2
I had the same problem and found this solution works. However, what I'm now trying to do is create Tag which takes date string as parameter and does the same conversion. For some reasen the two lines of code in tag don't work even they work in the jsp-page.

Here is my TAG, displayDate.tag:

And from the jsp-page I try to call it like this:

when the web:displayDate tag is executed I got exception:

What is causing that the code works on the jsp-page but not inside the tag ?

Best Regards,

PetriJ Airio
I agree. Here's the link:
subject: jstl reformat date exception
It's not a secret anymore!