Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

jstl reformat date  RSS feed

 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have dates coming from mysql database in format
2006-11-20 00:00:00.0
I get them with the code below. I wonder if there is a way to use some sort of jstl library to use the space between date and time and get rid of the time (ie keep only 2006-11-20 part of the string). Thanks in advance.
 
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you looked at the jstl formatting actions?

e.g. <fmt:formatDate />

Do you have a copy of the jstl spec? The JspFaq has links to the specs.
 
Author and ninkuma
Marshal
Posts: 66804
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by liliya woland:

I have dates coming from mysql database in format
2006-11-20 00:00:00.0



Unless you are storing the dates in the DB as strings (you aren't, are you?), dates have no format associated with them until printed out.

I wonder if there is a way to use some sort of jstl library to use



Have you checked with the JSTL Specification? You will find that the answer is "yes".
 
liliya woland
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I store the date in the database as DATETIME, which means I wont be able to use the jstl library you were mentioning above.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66804
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not?
 
liliya woland
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For some strange reason, when attempt using fmt:formatDate with the date that I have or with the date from java.util.Date I get same error about attribute value. I do include the library in my jsp page.


I get this error
org.apache.jasper.JasperException: /eng/episFindResponse.jsp(133,3) According to TLD or attribute directive in tag file, attribute value does not accept any expressions
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66804
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is usually a sign of mismatched JSP and JSTL versions. What versions of JSP and JSTL are you using? (according to forum instructions you should have already included this information).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!