• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

jstl reformat date exception

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67682
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Exactly, in the same way you couldn't pass a string to a method expecting a java.util.Date.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
They worship nothing. They say it's because nothing lasts forever. Like this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic