aspose file tools*
The moose likes JDBC and the fly likes problem printing a date from the database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "problem printing a date from the database" Watch "problem printing a date from the database" New topic
Author

problem printing a date from the database

Charles Diskin
Greenhorn

Joined: Mar 03, 2006
Posts: 19
hello, I am having a problem printing a date in the MM/DD/YYYY format. It is an Access DB and inside the tables it is stored as: 03/16/2006 but when it is pulled out and printed on a web page it is displayed as: 2006-03-16. Here is the code-



I was wondering if anyone knows how I can get the orignal format (MM/DD/YYYY) to display.Thanks in advance
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30780
    
157

Charles,
Instead of getting it as a String, get it as a Date using rs.getDate(). Then you can use SimpleDateFormatter to get any format you wish.

This also has the benefit of not being dependent on the driver/database.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem printing a date from the database