• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

jstl reformat date

 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67754
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

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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67754
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
Why not?
 
liliya woland
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67754
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
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).
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic