File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

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


SCJP5
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:


Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61314
    
  66

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
PetriJ Airio
Greenhorn

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
 
GeeCON Prague 2014
 
subject: jstl reformat date exception