Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jstl reformat date exception

 
Shilpa Tendulkar
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64632
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly, in the same way you couldn't pass a string to a method expecting a java.util.Date.
 
PetriJ Airio
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic