This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes JDBC and Relational Databases 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 and Relational Databases
Bookmark "problem printing a date from the database" Watch "problem printing a date from the database" New topic

problem printing a date from the database

Charles Diskin

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

Joined: May 26, 2003
Posts: 32320

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.

[OCA 8 book] [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
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: problem printing a date from the database
It's not a secret anymore!