File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Date Formatting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Date Formatting" Watch "Date Formatting" New topic

Date Formatting

jaya sudha

Joined: Jun 18, 2004
Posts: 20
Hi Every one........

In my Database table i have a date column when im trying to retrieve a particular date using JDBC im not getting the right date format..

in Table : 7/7/2004

when im retrieving using JDBC using

String strDate = rs.getString("my_date");

this is displayed..January 1, 1970, 00:00:00 GMT
But i want to disply it as 01/01/1970


Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

First - recover the date from your ResultSet as a Date, not a String. Second - look at java.text.SimpleDateFormat. That should make it clear.
[ July 08, 2004: Message edited by: Paul Sturrock ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
I agree. Here's the link:
subject: Date Formatting
It's not a secret anymore!