Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jstl reformat date  RSS feed

 
liliya woland
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.
 
Carol Enderlin
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65825
134
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: 65825
134
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: 65825
134
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).
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!