• 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:

fmt:parseDate with SQL Date

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm pulling a date out of a SQL Server database to display on a JSP, but the format isn't terribly user friendly. It looks like the following: 2006-07-19 00:00:00.0. I'd like it to look more like: July 19, 2006. I think <fmt:parseDate> will do the job, but I'm a little unclear on its use. I thought the following was what I needed:


This doesn't work, however. I also looked at <fmt:formatDate>, but it looks as though that only works with the java.util.Date data type. Can someone give me some direction?
[ March 15, 2006: Message edited by: Craig Dixon ]
 
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 Craig Dixon:
I'm pulling a date out of a SQL Server database to display on a JSP, but the format isn't terribly user friendly.



Dates don't have inherent formats. What you are seeing is the result of a simple toString() conversion.

I think <fmt:parseDate> will do the job



<fmt:parseDate> is used to convert strings to dates. So, no.

What you need is <fmt:formatDate>.

but it looks as though that only works with the java.util.Date data type.



A java.sql.Date is a java.util.Date.
 
Craig Dixon
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a bunch. Not sure why I had so much trouble with that.
 
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
Sometimes it just takes someone to nudge ya...
 
reply
    Bookmark Topic Watch Topic
  • New Topic